
正文
vb.net关闭文件,vb窗口关闭事件
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
VB中文件的打开与关闭
你都用.net了,这是vb的旧语法,不推荐使用。vb.net是面向对象的,推荐您使用
dim
opf
as
new
io.filestream(openfiledialog1.filename,
io.filemode.open)
...
opf.close
或是
using
opf
as
new
io.filestream(openfiledialog1.filename,
io.filemode.open)
...
end
using
但是你如果执意要用的话,也可以:
fileopen(1,
openfiledialog1.filename,
openmode.input)
...
fileclose(1)
'这里可以同时关闭多个文件号,文件号之间用,隔开
相关问答
Q1: vb.net如何关闭读取过的文件夹?
你都用.net了,这是vb的旧语法,不推荐使用。vb.net是面向对象的,推荐您使用
dim OpF as new io.filestream(OpenFileDialog1.FileName, IO.FileMode.Open)
...
OpF.close
或是
Using OpF as new io.filestream(OpenFileDialog1.FileName, IO.FileMode.Open)
...
End Using
但是你如果执意要用的话,也可以:
FileOpen(1, OpenFileDialog1.FileName, OpenMode.Input)
...
FileClose(1) '这里可以同时关闭多个文件号,文件号之间用,隔开
Q2: VB.net如何关闭已打开的文件夹
appid = Shell("explorer.exe c:\windows", vbNormalNoFocus)
If appid 0 Then Shell "Taskkill /PID " appid, vbHide
Q3: 怎样才能用VB.NET的代码来关闭一个在运行的程序
软糖来回答罗:通过System.Diagnostics命名空间下的Process类来关闭程序的进程
Dim 进程集合 = Process.GetProcessesByName("进程名称")
For Each 进程 In 进程集合
进程.Kill()
'进程.Close() '或者使用关闭
Next
也可以先获取所有进程,再来判断这些进程的名称ProcessName
Dim 获取本地所有进程 = Process.GetProcesses()
For Each 进程 In 获取本地所有进程
If 进程.ProcessName = "explorer.exe" Then 进程.Kill()
Next







