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

Getting Error on docLocation Illegal characters in path.

It might be helpful,

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
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
Tarun.K.S 8-Aug-11 7:31am    
Good suggestion. 5+

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