|
Error: The given path's format is not supported.
I am trying to upload from a page to the webserver and I got this error.
the code is just this
public void Upload_ServerClick(object sender, System.EventArgs e)
{
string baseLocation = "ftp://layer3media.com/DataGroup/Test/";
string status = "";
Label1.Visible=true;
foreach(System.Web.UI.HtmlControls.HtmlInputFile HIF in hif)
{
string fn = System.IO.Path.GetFileName(HIF.PostedFile.FileName);
HIF.PostedFile.SaveAs(baseLocation + fn);
filesUploaded++;
status += fn + "
";
}
}
}
Pravin
|
|
|
|
|
pavya_Cool wrote: HIF.PostedFile.SaveAs(baseLocation + fn);
will not work when baseLocation is string baseLocation = "ftp://layer3media.com/DataGroup/Test/";
You may need to save the file to a temporary location and use a FTP Client API to transfer it to an appropriate FTP folder.
|
|
|
|
|
Hello,
pavya_Cool wrote: string baseLocation = "ftp://layer3media.com/DataGroup/Test/";
use:
string baseLocation = "ftp://layer3media.com//DataGroup//Test//";
or:
string baseLocation = @"ftp:/layer3media.com/DataGroup/Test/";
-- modified at 4:38 Tuesday 28th August, 2007
Useless post!
All the best,
Martin
|
|
|
|
|
Escape characters begin with '\', not '/' -- "\D" wouldn't even compile...
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|
No comment!
All the best,
Martin
|
|
|
|
|
Martin,
Your @ prefix suggestion to override ESCape character was good. However, I don't think classes in System.IO namespaces support network file transfers.
|
|
|
|
|
Hi
I am using Visual Studio 2005 and C# for a Windows application. I am referencing a class in a different namespace from my main class. When I try to debug it tells me "There is no source code available for the current location." When I look at the properties of the reference, the path to the other namespace is correct. Also when I run it it does call the correct methods in the other namespace.
It is just very frustrating that I cannot debug it.
Anybody else seen this before.
Thanks.
Kobus
|
|
|
|
|
Is your project compiled in DEBUG mode and you have all required PDB files in place?
|
|
|
|
|
I did.
1.) It happens when an exception occurs within Framework .NET. The solution is to put a breakpoint before a certain excpetion occurs (you have to find out an approximate location in the code) and then debug step by step up to the broken code. The fastest way is to put a breakpoint before the method call (not inside it's body).
2.) Check if your use "Debug" configuration (not "Release"), because some stuff may be optimized out.
3.) You are able to debug only if you reference to a project (when u can access the code through IDE), not just a DLL file.
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|
I want to read external application exe name when it’s focused. It’s like this.
Consider now MSWord, Notepad and Google Talk are running in my computer as minimized (nothing focused). If I will click on notepad icon at taskbar to restore it, I want to pop-up a message box to say application name as Notepad.exe (because now it’s the focused application).
Please help me. Thanks.
|
|
|
|
|
Hello,
I think the "System.Diagnostics.Process" in combination with "user32.dll" method "IsIconic" could help you.
I did a little test:
First I Import the method from the user32.dll:
[System.Runtime.InteropServices.DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool IsIconic(IntPtr hWnd);
I declare two ArrayList: one for all processes (with mainwindowhandle), and one for the Procceses which state is Iconic.
using System.Collections;
private ArrayList ProcessesWithMainWindow = new ArrayList();
private ArrayList ProcessesIconic = new ArrayList();
Then I have a method which checks all Process.
If the process has a mainwindowhandle, it will be added to a ArrayList for further usage.
Additionally I enable the "EnableRaisingEvents" property of the processes and handle the "Exited" Event.
private void SearchRunningProcesses()
{
Process[] allRunningProcesses= Process.GetProcesses();
foreach(Process actProcess in allRunningProcesses)
{
if(actProcess.MainWindowHandle!=IntPtr.Zero)
{
if(!ProcessesWithMainWindow.Contains(actProcess))
{
ProcessesWithMainWindow.Add(actProcess);
actProcess.EnableRaisingEvents = true;
actProcess.Exited+=new EventHandler(actProcess_Exited);
}
}
else
{
actProcess.Dispose();
}
}
}
Then I added a method which validates the Processes inside the "ProcessesWithMainWindow " List, by checking "IsIconic".
If a processes mainwindow is iconic, I add it to the "ProcessesIconic" List.
If it is not iconic but is in the "ProcessesIconic" List, it would mean that the state of the meinwindow has changed and you could show your messagebox there.
private void ValidateProcesses()
{
foreach(object actObject in ProcessesWithMainWindow)
{
Process actProcess = actObject as Process;
if(actProcess.MainWindowHandle!=IntPtr.Zero)
{
if(IsIconic(actProcess.MainWindowHandle))
{
if(!ProcessesIconic.Contains(actProcess))
{
ProcessesIconic.Add(actProcess);
}
}
else
{
if(ProcessesIconic.Contains(actProcess))
{
ProcessesIconic.Remove(actProcess);
}
}
}
}
}
If the Exited event of a process get's fired, I remove the instance out of the collections, unregister the event and dispose it.
private void actProcess_Exited(object sender, EventArgs e)
{
Process actProcess = sender as Process;
ProcessesWithMainWindow.Remove(actProcess);
if(ProcessesIconic.Contains(actProcess))
{
ProcessesIconic.Remove(actProcess);
}
actProcess.Exited-=new EventHandler(actProcess_Exited);
actProcess.Dispose();
}
You can call the two methods in a tick or elapsed event of a timer.
SearchRunningProcesses();
ValidateProcesses();
Note: I just did a quick test, which means that it might not work under all conditions.
Hope it helps!
-- modified at 6:17 Tuesday 28th August, 2007
actProcess = null;
All the best,
Martin
|
|
|
|
|
Dear Martin,
Thank you very much for your valuable time and knowledge. Now I am trying to apply the method you mentioned. If there will be any question then I will continue this thread again. Thanks.
|
|
|
|
|
You are wellcome!
All the best,
Martin
|
|
|
|
|
Hi,
I'm currently in the process of developing an utility that executes the SQL Query's.
(More or less similar to SQL QUERY ANALYZER).
I have defined the Database name in the App.config file itself.
And , t's working fine.
Now the problem is, I need to modify the Database Name in the App.config while I select the
Database name from the Listbox automatically.
The app.config file code is
<configuration>
<appsettings>
<add key="QueryAnalyzer" value="Data Source=(local);Integrated Security=True;User ID=;Password=;Initial Catalog=Northwind">
Please any one help me in finding the solution
BhuMan
|
|
|
|
|
I am working on an existing c# code which reads .csv files.
Some of these files are about 120 MB in size.
When the program is going through these big files it produces the following error.
Message: "Exception of type 'System.OutOfMemoryException' was thrown."
I have been asked to solve this issue in the code.
Any thoughts please?
Thanks
|
|
|
|
|
Hello,
A wild guess:
Maybe you are not Closing / Disposing the file streams!
It would help us to help you, if you show some code snippeds.
All the best,
Martin
|
|
|
|
|
|
To me this happend when I created a non terminating recursion. Maybe you are hanging in some loop? Forgot to increase the index while creating new objects?
Rudolf Heijink
|
|
|
|
|
Hi People...
My boss (and project leader) comes from the Visual Object environment... and is concerned about the use of SortedLists because of memory performances.
Can somebody tell me when the Garbage Collector is called to clean sorted lists that are not used anymore?
I.E.: we use a sorted list to do some calculation in a method. When will this sorted list be cleaned? at the end of the method or when we call the dispose() method of the container?
Thanks a lot
|
|
|
|
|
Hello,
JoZ CaVaLLo wrote: and is concerned about the use of SortedLists because of memory performances.
This is what the documentation say:[^]
Operations on a SortedList object tend to be slower than operations on a Hashtable object because of the sorting. However, the SortedList offers more flexibility by allowing access to the values either through the associated keys or through the indexes.
JoZ CaVaLLo wrote: Can somebody tell me when the Garbage Collector is called to clean sorted lists that are not used anymore?
No, the GC will clean up your object when he wants and is able to do so!
But, he is only able if there are no references left, which hold the instance of the sorted List.
Therefor you have to call the Dispose() method.
The Dispose method frees the instance from unmanaged resources.
If you are creating and using an instance of the SortedList inside of a method, I would suggest a "using"-block.
sample code:
private void YourMethod()
{
using(SortedList yourSL = new SortedList())
{
yourSL.Add(....
}
}
If you have a SortedList instance as a member of a class, you should implement "IDisposable" in your class,
and dispose the instance of SortedList at the Dispose method of your class.
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(yourSL != null)
yourSL.Dispose();
}
base.Dispose( disposing );
}
Additionaly:
Interesting disussion here on the forum![^]
How To Dispose by Joe Duff[^]
Implement IDisposable by Scott Dorman[^]
Hope it helps!
All the best,
Martin
|
|
|
|
|
Hi Martin,
Martin# wrote: But, he is only able if there are no references left, which hold the instance of the sorted List.
Therefor you have to call the Dispose() method.
Martin# wrote: using(SortedList yourSL = new SortedList())
SortedList does not implement IDisposable, the code snippet will not compile.
A SortedList item will be garbage collectable as soon as no references to it
exist any longer.
An item in a SortedList will be garbage collectables as soon as the reference
to it inside the SortedList becomes the last reference AND the
SortedList becomes collectable.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Ooops!
True, Only have .Net 1.1 so I couldn't test it, but same with ArrayList and Hashtable!
Thanks, for pointing it out!
All the best,
Martin
|
|
|
|
|
Hi Joz,
The GC runs when it needs to run, i.e. when your process needs free memory
(because you are creating a new object, typically with the "new" keyword)
and the OS does not give it more memory, so it has to go and look if anything
it holds can be thrown out. The execution of the GC is not periodic, and
is not invoked by closing a scope (as in returning from a method).
A SortedList is not threated any different by the GC than any other object.
A SortedList item will be garbage collectable as soon as no references to it
exist any longer.
An item in a SortedList will be garbage collectables as soon as the reference
to it inside the SortedList becomes the last reference AND the
SortedList becomes collectable.
"garbage collectable" means the next time GC runs it will be able to collect
the object (i.e. actually collecting it, or putting it on the finalizing list,
which is handled by a separate GC thread).
SortedList does not implement IDisposable, the code snippet using (... SortedList)
will not compile, because SortedList does not implement IDisposable.
Hope this helps.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Is there any free open source viewers for .Net that supports SVG.
I tried with Adobe SVG viewer 3.03 ,but can't figure out any way to add it in the toolbox.
|
|
|
|
|
SVG needs to be installed on the client. Then you can generate SVG using any classes you like. The Adobe viewer is the file that your user needs to install, it doesn't get added to the toolbox.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|