如何检查服务器上的文件是否存在(update.date.txt) [英] How do check if a file exsits on a server (update.date.txt)

查看:111
本文介绍了如何检查服务器上的文件是否存在(update.date.txt)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为游戏启动器制作更新系统,这就是为什么我要检查这个文件是否存在的原因:

更新。[datestring] .txt

每个更新的日期字符串将不同,以便更新程序可以使用本地文件检查这个,如果这两个不是机器人(所以如果有更新的版本),启动器将下载新的更新



我该如何查看



代码到目前为止:



 如果 My.Computer.FileSystem.FileExists(Application.StartupPath&    update / Update。[datestring] .txt然后 
MsgBox ( 找到文件。
Else
MsgBox( 找不到文件。
< span class =code-keyword> E. nd 如果





请帮帮我



问候



Bart de Lange

解决方案

使用使用以下方法之一在目录中搜索文件:

http://msdn.microsoft.com/en-us/library/wz42302f%28v=vs.110%29.aspx [ ^ ],

http://msdn.microsoft.com/en-us/library/ms143316%28v= vs.110%29.aspx [ ^ ]。



一切都取决于你如何选择文件掩码(第二个参数, searchPattern )。要获取所有文件,请使用update。* .txt或* .txt或update。*。或按年份选择:* .2014.txt。等等...



获取一系列文件名,然后按照你描述的方式对它们进行分析。



正如我所说,你有一个问题:糟糕的目录选择。一般来说,它是只读的。请看我过去的答案:

http://www.codeproject.com/Questions/454593/How-to-find-my-programs-directory

如何查找我的程序目录可执行目录),

如何查找我的程序目录当前目录,特殊文件夹 )。



此外,请注意这个小问题,以防万一:

Directory.Get.Files搜索模式问题 [ ^ ]。



-SA


它不是太复杂。看看这里: http://stackoverflow.com / questions / 1979915 / can-i-check-if-a-file-exists-at-a-url [ ^ ] - 它建议使用HttpWebRequest,它可以正常工作。



如果要列出Web资源中的文件并检查最新版本,请参阅此处:http://stackoverflow.com/questions/124492/c-sharp-httpwebrequest-command-to-get-directory-listing [ ^ ]

Im making an updating system for a game launcher and that's why i'm trying to check if this file exists:
Update.[datestring].txt
the datestring wil be different every update so that the updater can check this with the local file if the two do not mach
(so if there is a newer version) the launcher will download the new update

how can i check this

Code so far:

If My.Computer.FileSystem.FileExists(Application.StartupPath & "update/Update.[datestring].txt") Then
    MsgBox("File found.")
Else
    MsgBox("File not found.")
End If



please help me

Regards

Bart de Lange

解决方案

Use the file search in the directory using one of these methods:
http://msdn.microsoft.com/en-us/library/wz42302f%28v=vs.110%29.aspx[^],
http://msdn.microsoft.com/en-us/library/ms143316%28v=vs.110%29.aspx[^].

Everything depends on how you chose the file mask (second parameter, searchPattern). To take all files, use "update.*.txt" or just "*.txt" or "update.*". Or select by year: "*.2014.txt". And so on…

Obtain an array of file names and then analyze them the way you described.

As I say, you have one problem: bad choice of directory. Generally speaking, it is read-only. Please see my past answers:
http://www.codeproject.com/Questions/454593/How-to-find-my-programs-directory
How to find my programs directory (executable directory),
How to find my programs directory (current directory, "special folders").

Also, be aware of this minor problem, just in case:
Directory.Get.Files search pattern problem[^].

—SA


It's not too complex. Have a look here: http://stackoverflow.com/questions/1979915/can-i-check-if-a-file-exists-at-a-url[^] - it suggests using an HttpWebRequest, which will work fine.

If you want to list the files in the web resource and check for the latest version, then see here: http://stackoverflow.com/questions/124492/c-sharp-httpwebrequest-command-to-get-directory-listing[^]


这篇关于如何检查服务器上的文件是否存在(update.date.txt)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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