0

Hi I m getting this error when I save a file in asp.net. I have put my application inside a folder containing space in the name.

Illegal characters in path. 
System.ArgumentException: Illegal characters in path. 
at System.IO.Path.CheckInvalidPathChars(String path) 
at System.IO.Path.GetFileName(String path) 
at MyApp.Localization.LocalizationHelper.GetDefaultFilePath(String filepath) in D:\!  sf02_jan09_I\MyApp.Localization\Helper\LocalizationHelper.cs:line 36 
at Localization_Language.Save(String filePath, List`1 lstResDef) in d:\!  sf02_jan09_I\MyApp\Modules\Language\LanguageManager.ascx.cs:line 810
at Localization_Language.imbUpdate_Click(Object sender, ImageClickEventArgs e) in d:\! sf02_jan09_I\MyApp\Modules\Language\LanguageManager.ascx.cs:line 743

When I remove the space from !sf02_jan09, it works..how do i handle saving file in this scenario?

Amar Palsapure
  • 9,590
  • 1
  • 27
  • 46
Paras
  • 2,997
  • 6
  • 35
  • 46
  • maybe this help http://stackoverflow.com/questions/146134/how-to-remove-illegal-characters-from-path-and-filenames If the space is the problem include your file name inside "". Eg "c:\file name" – Aristos Jan 09 '12 at 11:51

3 Answers3

3

space is not an illegal character - I suspect your problem is something else:

MSDN: Naming Files, Paths, and Namespaces

Nick Butler
  • 24,045
  • 4
  • 49
  • 70
2

....in D:!

It's the exclamation point!

Steve Wellens
  • 20,506
  • 2
  • 28
  • 69
0

Meybe you should do some input validation on file names with illegal characters, instead of trying to change the name of the file?

T23
  • 582
  • 2
  • 11