检查文件是否存在 [英] Check file if exist

查看:89
本文介绍了检查文件是否存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何插入代码?信息,如果该文件是由其他程序打开                   &NBSP ;                        &NBSP ;                        &NBSP ;          
dim cse_name as string = sr_name +" output.cse"                                                                                                                   
如果file.exists = true,那么...                                                                                                                                                      
dim i1 as Integer = mesgbox(" ...,vbyesno)    ENDIF                                                                                                                                                                           &NBSP ;                        &NBSP ;  


How can i insert a code for Info if the file is opened by an other program.                                                                                 dim cse_name as string = sr_name + " output.cse"                                                                                                                if file.exists = true then ...                                                                                                                                                 dim i1 as Integer =mesgbox("..., vbyesno)    endif                                                                                                                                                                                                 

sw1 = new IO.Streamwriter(cse_name)   - >所以这里IOException问题,如果文件被打开。我怎样才能解决这个问题... 谢谢

sw1 = new IO.Streamwriter(cse_name)   -> so here IOException problem if file is opened. How can i solve this problem...  Thanks

推荐答案

你好lLikePP,

Hi lLikePP,

假设(如果文件未在其他任何地方打开):您打开已打开的文件。确保所有已打开的流正常关闭。您也可以使用此语法。

Assumption (if file was not opened anywhere else) : You open already opened one.Make sure that all your opened streams closed properly. You can use this syntax too.

Using writer As StreamWriter = New StreamWriter(file)
        writer.Write("....")
           //and so on
End Using

最好的问候,

Cherry


这篇关于检查文件是否存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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