asp.net mvc file path issue \
صفحه اصلي

asp.net mvc file path issue \



i am using this to create a new folder

 System.IO.Directory.CreateDirectory(@" + somevariable);  

the thing is that when i enter the folder c:\newfolder\newfolder in the textbox and is trying to recieve the value up in the controller it is replaced with double slash( \) c:\\newfolder\\newfolder. how would i prevent \ quotes from coming in the path

Secondly the string.replace is also not working for replacing \ with \\

  string strText = OrganMeta.vcr_MetaValue;     string gf = strText.Replace("\\", @"\"); 

How do you serialize a JS array so Asp.net MVC can bind it to a c# list?

1:

ASP.NET asynchronous controllers and calling Sync(); what is “Sync()”?
"\\" is equivalent to a string of one character, a backslash. how to return different view from different method in controller in MVC@"\" is also equivalent to a single character, a backslash. Error while parsing a Json object. Can I pass an enum into a controller so the Model Binder binds it? so your Replace method is replacing one form of a backslash with a different form.. Razor/CSHTML - Any Benefit over what we have? [closed] try this:. Multiple Types of Authorizations in .NET MVC 2.0
string gf = strText.Replace( @"\\", @"\" ); 
OR . Why can't I bind form data directly to action method parameter?
string gf = strText.Replace( "\\\\", "\\" ); 
as far as the folder thing goes, Andy is right, it will show a double-backslash in the IDE when in fact there is only one in the string. is there an error when Directory.CreateDirectory() is called? or is the folder created?.

2:

Are you sure it's replaced it with \\? If you hover over the variable it will appear to have \\ where there should be a single \ although if you view it in the text visualizer it will show correctly.. Not sure what you mean by string.replace is not working...?? Can you commit an case of the code that's not working?.

3:

Slashes don't receive doubled between the form submit and your controller action. . It's far more likely this you're viewing the result in the debugger or ananother context this shows two slashes to allow you to distinguish between escaped characters (\n) and a literal slash (). . Write the string to the debug window to verify this..
System.Diagnostics.Debug.WriteLine("SomeText");  


72 out of 100 based on 32 user ratings 352 reviews