. Advertisement .
..3..
. Advertisement .
..4..
I have the following csharp code, but I do not know how to find the correct result. Why has this problem occurred, and how can it be solved? Here is the code that I am running:
string str_uploadpath = Server.MapPath("/UploadBucket/Raw/");
FileStream objfilestream = new FileStream(str_uploadpath +
fileName, FileMode.Create, FileAccess.ReadWrite);
And this is the error text I receive:
The given path's format is not supported
The cause:
You received the error ”the given path’s format is not supported” because you wanted to save a file to the file path. However, your filename was not exact because it contained some null characters, so the given format of path had no assistance.
Solution:
To solve this problem, let’s use
System.IO.Path.Combine
instead ofstr_uploadpath + fileName
as the following:A string will be returned.
Or you can exclude the null characters from your file names by:
And the operation is:
The error occurred when the filename was saved with an entire path. To get this error, you only need to have
":"
in your file name. You should replace any":"
found in your file names (e.g. a date stamp). I.e: