[英]uri formats are not supported for Ip address in C#
In my Web.Config file I have add my IP address in file path. 在我的Web.Config文件中,我在文件路径中添加了IP地址。 when i try to access all files of that folder then it gives an error uri format not supported.
当我尝试访问该文件夹的所有文件时,它给出了不支持的错误uri格式。 but if i give local file path then it works fine.
但是,如果我给出本地文件路径,则可以正常工作。
string pathdata = Utility.GetConfigValue("DevSubmittedStateTaxForms");
string uploadPath = Utility.GetConfigValue("DevUploadFiles");
DirectoryInfo d = new DirectoryInfo(pathdata);
FileInfo[] Files = d.GetFiles("*.pdf");
var status = new List<Object>();
int i = 1;
foreach (FileInfo filename in Files)
{
status.Add(new {ID = i, Name = filename.Name, URL = pathdata + filename.Name + ".pdf" });
i++;
}
using System;
using System.IO;
namespace Test
{
public class Program
{
static void Main(string[] args)
{
string pathdata = @"\\192.168.1.27\Temp\";
var d = new DirectoryInfo(pathdata);
var files = d.GetFiles("*.pdf");
foreach (var filename in files)
{
Console.WriteLine(pathdata + filename.Name + ".pdf");
}
Console.ReadLine();
}
}
}
The above code does work (on my machine - that is my current IP address and a folder I have shared on my machine). 上面的代码确实有效(在我的机器上-这是我当前的IP地址和我在机器上共享的文件夹)。 Your code likely doesn't work for one of two reasons:
您的代码可能由于以下两个原因之一而无法运行:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.