Click here to Skip to main content
15,880,392 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
if (!Directory.Exists(UploadPath + docLocation))
                {
                    Directory.CreateDirectory(UploadPath + docLocation);
                }
                FileUploadCtrl.SaveAs(UploadPath + docLocation + "\\" + OtherFileName);


Getting Error on docLocation Illegal characters in path.
Posted

First thing, use Path.Combine to concatenate path.
And check you docLocation variable's value whether it contains illegal characters. Or please post the docLocation variable's value, so we can help you.
 
Share this answer
 
v2
Comments
Tarun.K.S 8-Aug-11 7:31am    
Good suggestion. 5+
It might be helpful,

C#
if (!Directory.Exists(Path.Combine(UploadPath, docLocation)))
{
    Directory.CreateDirectory(Path.Combine(UploadPath, docLocation));
}
var result = Path.Combine(UploadPath, docLocation, OtherFileName);


Behind the scene Combine method will check for the invalid characters using Framework's CheckInvalidPathChars(string item).

:)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900