Replacing delimiter characters in file path

Posted by salvationishere on Stack Overflow See other posts from Stack Overflow or by salvationishere
Published on 2010-04-14T21:52:30Z Indexed on 2010/04/14 22:03 UTC
Read the original article Hit count: 237

Filed under:
|
|
|

I'm developing a C# web application in VS 2008. I let the user select an input file and then I store the file path in a string variable. However, it stores this path as "C:\\folder\\...". So my question is how do I convert this file path into single "\"?

To clarify more, this is my code in context. Currently it is entering the If Directory does not Exist section.

 protected void btnAppend_Click(object sender, EventArgs e)
{
   string fullpath = Page.Request.PhysicalPath;
    fullpath.Replace('\\', '\');

    if (!Directory.Exists(fullpath))
    {
    string msg = "<h1>The upload path doesn't exist: {0}</h1>";

© Stack Overflow or respective owner

Related posts about c#

Related posts about vs2008