创建用于从不同计算机访问文件的文件路径 [英] Creating filepath for accessing files from different computers

查看:63
本文介绍了创建用于从不同计算机访问文件的文件路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个浏览远程计算机中文件的应用程序。当我在另一台计算机上使用该应用程序时,它不起作用,因为浏览文件的文件路径是我安装了visual studio并编写vb.net代码的计算机。

是有可能提供一般文件路径,以便在我启动应用程序时可以访问其他计算机上的文件吗?



我尝试过:



我试过改变代码本身的文件路径但是不可行。

I have created an application which browses for a file in the remote computer. When i use that application in a different computer it doesn't work because the filepath through which the file is browsed is of the computer where i have installed visual studio and written the vb.net code.
Is it possible to give a general filepath so files from other computers can be accessed when i launch the application in them?

What I have tried:

I have tried changing the filepath in the code itself but it's not feasible.

推荐答案

那里有两种方法可以解决这个问题:一种方法是使用绝对引用 - \\Computername \ Path \ .Filename但这仍然是一个坏主意,因为如果计算机死机并且您必须将数据移动到新PC ,你再次遇到同样的问题。

另一种是使用配置文件并从那里读取路径:这样每台计算机都可以使用最合适的文件路径,并且可以更改没有重新压缩如果发生变化,请采取措施。
There are two ways to approach this: one is to use an absolute reference - "\\Computername\Path\Filename" but that's still a bad idea because if the computer dies and you have to move the data to a new PC, you get the same problem again.
The other is to use a configuration file and read the path from there: that way each computer can use the most appropriate file path for it, and it can be changed without recompilation in the event of changes.


这篇关于创建用于从不同计算机访问文件的文件路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆