如果文件位于 Internet 中,如何将文件传输到函数

发布于 2024-09-28 22:04:20 字数 417 浏览 4 评论 0原文

我有一个文件位于路径 http://www.site.ru/config.ini

还有其他人的代码获取了应该位于计算机(本地)上的文件。

你当然可以保存文件,然后通过,但我无法在本地保存文件(这不会是谁无法使用它)。

功能:

[DllImport ("kernel32")]
        private static extern int GetPrivateProfileString (string section, string key, string def, StringBuilder retVal, int size, string filePath);

我要做什么?

I have a file that lies on the path http://www.site.ru/config.ini

And there is someone else's code that takes a file that should be on the computer (locally).

You can of course save the file, and then pass, but I can not save the file locally (which would not be who could not work with it).

Function:

[DllImport ("kernel32")]
        private static extern int GetPrivateProfileString (string section, string key, string def, StringBuilder retVal, int size, string filePath);

What shall I do?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

甜心 2024-10-05 22:04:20

也许通过 http 将文件下载到流可能会有所帮助。

我在 csharpfriends.com 上找到了如何执行此操作的示例:

public form1()
{
    InitializeComponent();

    System.Net.WebClient Client = new WebClient();
    Stream strm = Client.OpenRead("http://www.csharpfriends.com");
    StreamReader sr = new StreamReader(strm);
    string line;
    do
    {
        line = sr.ReadLine();
        listbox1.Items.Add(line);
    }
    while (line !=null);
    strm.Close();
}

maybe downloading the file to a stream via http might be helpful.

I found an example on how to do this on csharpfriends.com:

public form1()
{
    InitializeComponent();

    System.Net.WebClient Client = new WebClient();
    Stream strm = Client.OpenRead("http://www.csharpfriends.com");
    StreamReader sr = new StreamReader(strm);
    string line;
    do
    {
        line = sr.ReadLine();
        listbox1.Items.Add(line);
    }
    while (line !=null);
    strm.Close();
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文