|
Hello.
I'm trying upload a file which name contains '#', for example: '#1.doc', or 'myFile#125.exe' to WebDAV Server, which is running on Linux.
I use HttpUtility.UrlEncode() Method for encoding URL, but everytime the result will be files with name '1.doc' and 'myFile' on the server.
Please, give some advice.
Thank you.
|
|
|
|
|
Can you please show us the code?
HttpUtility.UrlEncode() Method will replace the
# with
%23
Better, try your code without this method.
// ♫ 99 little bugs in the code,
// 99 bugs in the code
// We fix a bug, compile it again
// 101 little bugs in the code ♫
|
|
|
|
|
|
I do use HttpUtility.UrlEncode().
But it's not replacing # to %23, simply, leaving it as it is.
So, I replaced # to %23 manually.
Now it's working.
Thank you.
|
|
|
|
|
Uri.EscapeDataString
Should encode '#' (as well as others).
|
|
|
|
|
Thank you.
This is really a helpful method.
|
|
|
|
|
List<string> savedControls = new List<string>();
List<Control> formControls = new List<Control>();
private void button2_Click(object sender, EventArgs e)
{
savedControls.Clear(); formControls.Clear();
StreamReader sr = new StreamReader(path + "\\settings.txt");
string s = sr.ReadToEnd();
RichTextBox text = new RichTextBox();
text.Text = s;
foreach (Control c in this.Controls)
{
formControls.Add(c);
}
for (int i = 0; i <= text.Lines.Length - 1; i++)
{
savedControls.Add(text.Lines[i]);
}
for (int i = 0; i <= formControls.Count - 1; i++)
{
for (int j = 0; j <= savedControls.Count - 1; j++)
{
if (savedControls[j].Contains(formControls[i].Name))
{
savedControls[j] = savedControls[j].Replace(formControls[i].Name + "=", "");
}
}
}
sr.Close();
}
|
|
|
|
|
I am trying with this little code:
foreach (NumericUpDown num in this.Controls)
{
if (num.Name == formControls[i].Name)
{
num.Value = int.Parse(savedControls[j]);
break;
}
}
but it throws errors:
<br />
System.InvalidCastException was unhandled<br />
Message=Unable to cast object of type 'System.Windows.Forms.ProgressBar' to type 'System.Windows.Forms.NumericUpDown'.
|
|
|
|
|
Try this code instead:
foreach (Control num in this.Controls)
{
if ( ! ( num is NumericUpDown ) )
continue;
NumericUpDown numeric = (NumericUpDown)num;
if (numeric.Name == formControls[i].Name)
{
numeric.Value = int.Parse(savedControls[j]);
break;
}
}
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
its working ...thanks [Richard Andrew x64]
I must test it for other values and other controls...so until then this remain a open post.
|
|
|
|
|
this.Controls contains a set of all controls.
Since you need to access only a particular control, have a check (case or if statement) just for that type of control.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
|
|
|
|
|
I'm working on a project which is by C# language. I want to produce a Dictionary which is similar to Narcis or Easylingo that able the user to use the mouse and just move the cursor on the WORD in any application then the program detect the word and will find the meaning for that particular word.
My question is How I can detect the word which is under the Mouse Cursor on the screen in any application such as Microsoft office or Web browsers, etc.
I'm looking for any tips and guide or any Codes which can help me.
Your cooperation is highly appreciated.
|
|
|
|
|
I wonder if you can't grab an image of the area around the mouse position (like snaggit or something) and run that through some OCR library to parse out any text.
If you think you are going to be able to write a generic hook into any program to grab the text, good luck with that.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
You're going to have to OCR the screen around the mouse. There is no consistent way to get the text under the mouse cursor in every application window. WM_GETTEXT is not supported by every window.
|
|
|
|
|
Sounds like a CPU-hogging "solution".
Bastard Programmer from Hell
|
|
|
|
|
Yep, but you could make it less of a hog by only doing the OCR on a right-click.
|
|
|
|
|
I still think it's an exotic solution; you'd have to account for the resolution of the current desktop, and copy a part of it without knowing the size of the font under the word.
Bastard Programmer from Hell
|
|
|
|
|
Yep, it is. But I don't know of another way to get the text under the mouse that works with all controls...
|
|
|
|
|
Do any of you use the VS2010 Profiler regularly? If so, in what cases do you use it? I know there are plenty of paid profilers around, as well as free (IIRC, not entirely sure).
I ask because I recently ran into some terribly slow performance in a database-driven application. I did not have access to any 3rd-party profiling applications. So I ran the profiler in VS. It helped me discover that I had mistakenly created a loop which opened the database connection, queried it and the closed the connection for EACH iteration in the loop. This took approximately 27 seconds seeing as how there was close to 2,000 records in the table. The profiler told me that the majority of the time was taken up by DbConnection.Disconnect() inside this method. That's when I found the problem. Once I fixed it I can now run the same code with MORE THAN 2,000 records in the table and it takes ~7 seconds.
I think I should start using the profiler more often. Haha. Any input would be nice. I wasn't entirely sure if this was the correct forum but I develop C# applications.
|
|
|
|
|
I can't comment on the VS profiler as I use the JetBrains profiler. I'm surprised that you saw such a problem though - if your connections were pooled, they should just be returned to the pool (and taken from there), which is not an expensive operation.
|
|
|
|
|
Well, if it makes any difference I am using OLE DB with a Microsoft Access 2007 database. But either way, it happened. I thought it was odd as of last night because I had just recently read a thread here on CP concerning connection pooling and such. But I don't know. I have never developed an application that was entirely database-driven until this one. So I'll take any advice I can get, if you have any for me. :-P
|
|
|
|
|
In the normal sense it isn't possible to pool connections with MS Access because the is no such thing as a 'connection' in terms of network connections possible with that.
Your experience would suggest it isn't pooling any other associated resource either.
|
|
|
|
|
Matt U. wrote: I have never developed an application that was entirely database-driven until this one
Get rid of Access and use SQL Server express. Let me say that with emphasis GET RID OF ACCESS, seriously the absolute best thing you could do for both your application and yourself is move to SQL Server express, there are tools that will help move the structure and data.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
The database is not mine. It belongs to the plant manager. I have pitched the idea, along with numerous advantages, improvements, etc., with using SQL Server Express (including that it is 100% free). However, is there a way to pull SQL Server data into Access? He generates daily, weekly and monthly reports, which he must send to various individuals throughout the company. That is his biggest issue with the idea.
|
|
|
|
|
Matt U. wrote: However, is there a way to pull SQL Server data into Access?
Certainly, I'm not sure of the connection type any more but you could use Access as a front end to a SQL Server database, there is [used to be] a migration wizard. If your current design has 2 MDFs (database and UI) then the change is very simple. If not you may need to refactor some of your Access code.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Use a profiler if you have a problem or if you have time to learn about it.
However don't over optimize.
|
|
|
|