convert from physical path to virtual path

后端 未结 3 1045
野性不改
野性不改 2020-12-15 21:36

I have this function that gets the fileData as a byte array and a file path. The error I am getting is when it tries to set the fileInfo in the code bewlo. It says \'Physica

3条回答
  •  Happy的楠姐
    2020-12-15 21:42

    Working:

        string[] filesPath = Directory.GetFiles(Server.MapPath("~/txtPath/"));        
        foreach (string path in filesPath)
        {
            FileInfo fi = new FileInfo(path);      //This Is Working
           string LastAcceTime = fi.LastWriteTime; //Return Correct Value
        }
    

    Not Working:

        string[] filesPath = Directory.GetFiles(Server.MapPath("~/txtPath/"));        
        foreach (string path in filesPath)
        {
            FileInfo fi = new FileInfo(Server.MapPath(path));  //This Is Worng
           string LastAcceTime = fi.LastWriteTime;             //Return 1/1/1601 
        }
    

    Dont use Server.Mappath twice

提交回复
热议问题