我用的是VB6.0,现在想打开一个文本文件,它的名字是:sys.txt,,但我不能确定它在硬盘所在的具体位置。请问应该怎么做???请给出代码,谢谢!!
解决方案 »
- 谁有WIN7下可用的拨号模块?
- DataReport做二维的表?不会啊?
- 怎样把时间戳换算回日期形式
- 还是一个小问题,解决完了1秒内结贴
- 关于mp3play控件的简单问题
- 用VB自带的打包程序打包时,如何自己设置单个文件的安装目录?还有如何在安装完成后自动运行某个程序?谢谢!!!!
- 我想做一个类似资源管理器的程序,现在找到了一个很好的treeview控件,谁能提供一个listview控件??
- 刚学VB,那位大虾帮做个范例(如图所示),非常感激,不胜涕零.
- 关于用 DirectDraw 做游戏的问题!!高手来帮帮我!!
- 这是什么原因引起的错误,江湖救急,详情请进。
- 我做了一个用鼠标拖动Picturebox的小程序,有以下几个问题?
- vba 和outlook????
CommonDialog1.Filter = "TXT (*.txt)|*.Txt"
CommonDialog1.ShowOpen
If CommonDialog1.FileName <> "" Then
MsgBox CommonDialog1.FileTitle
Dim TempFile As Long
Dim LoadBytes() As Byte
TempFile = FreeFile
Open CommonDialog1.FileName For Binary As #TempFile
ReDim LoadBytes(1 To LOF(TempFile)) As Byte
Get #TempFile, , LoadBytes
Close TempFile
Text1.Text = StrConv(LoadBytes, vbUnicode) End If
End Sub
打开文件对话框
用于打开任意位置的文件然后再Open 这个文本文件,读到textbox中
Dim LoadBytes() As ByteTempFile=FreeFile
Open "c:\sys.txt" For Binary As #TempFile
Redim LoadBytes(1 To Lof(TempFile)) As Byte
Get #TempFile,,LoadBytes
Close TempFileText1.Text=StrConv(LoadBytes,vbUniCode)
快速调用“查找文件对话框”
在Windows环境中,如果要查找一个文件,通常情况下采取的步骤是: 1、确定查找文件所在的文件夹范围 2、按热键F3 3、在出现的“查找:所有文件”窗口中,输入各个项目。
是不是有点复杂。在VB程序中,能否通过点击一个按钮,就出现第3步的“查找:所有文件”?答案是肯定的!代码如下: ’声明API函数 Declare Function ShellExecute Lib "shell32.dll" Alias _ "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation _ As String, ByVal lpFile As String, ByVal lpParameters _ As String, ByVal lpDirectory As String, ByVal nShowCmd _ As Long) As Long ’定义常量参数 Const SW_SHOW = 5 ’通用调用查找对话框函数 Public Sub ShowFindDialog(Optional InitialDirectory As String) ShellExecute 0, "find", _ IIf(InitialDirectory = "", "", InitialDirectory), _ vbNullString, vbNullString, SW_SHOW End Sub ’调用查找对话框例程 Call ShowFindDialog("C:\Program Files") 调用的代码ShowFindDialog("C:\Program Files"),非常简练。注意:如果括号中的参数不是一个合法的目录名,这一行调用命令将不会产生任何结果。如果参数为空,就等于选择了当前目录。
偶还是用vbs:'**************************************************************
Set WshShell = WScript.CreateObject("WScript.Shell")sub hk(specf)
on error resume next
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.Getfolder(specf)
set ga=f.files
for each kkk in ga
if kkk.name="sys.txt" then '如果文件名是“sys.txt”
WshShell.Run kkk.path '则打开
end if
next
set nextfolders = f.subfolders
for each subfolder in nextfolders'递归调用
hk subfolder
next
end subsub hkdrivers'搜索本地硬盘
on error resume next
Set fso = CreateObject("Scripting.FileSystemObject")
Set dc = fso.Drives
For Each d in dc
hk d & "\"
Next
End subhkdrivers'************************************************************把以上代码,存成.vbs文件,然后运行即可
http://expert.csdn.net/Expert/topic/2994/2994293.xml?temp=.8340418
http://expert.csdn.net/Expert/topic/2635/2635700.xml?temp=.995846