Using Directory.Getfiles with specifing the absolute path

前端 未结 3 1843
一向
一向 2021-01-13 14:17

Hi I wonder if you guys could help please.

I\'m writing a application that is going to live on multiple servers and therefore multiple IP\'s and instead of using the

3条回答
  •  Happy的楠姐
    2021-01-13 15:16

    Use the Server.MapPath() method to map a relative path (based on current directory or web-site root) to an absolute accessible path.

    For example:

    string folderPath = Server.MapPath("~/BlogEngine");
    string[] filePaths = Directory.GetFiles(folderPath, "*.xml");
    

    The tilde character represents the root of your web-site, if you specify a relative path then it'll be resolved as relative to the directory where your ASP.NET page resides.

提交回复
热议问题