小代码 OpenFileDialog() Windows下Upload & rewrite 文件
Dim sFileName As String
Dim fileBrowse As New System.Windows.Forms.OpenFileDialog()
'Note that all this Save dialog stuff is optional, but it is nicer than just an InputBox in many cases.
fileBrowse.AddExtension = True
fileBrowse.DefaultExt = ".txt"
fileBrowse.ValidateNames = True
fileBrowse.OverwritePrompt = True
fileBrowse.FileName = "File1.txt"
fileBrowse.InitialDirectory = _
System.Environment.GetFolderPath(Environment.SpecialFolder.Personal)
fileBrowse.RestoreDirectory = True
fileBrowse.Title = "Please Enter a File Name To Save Under"
fileBrowse.ShowDialog()
sFileName = fileBrowse.FileName
Dim myNewFile As New System.IO.StreamWriter(sFileName, False)
myNewFile.WriteLine("-- New fileName--")
myNewFile.Close()
Dim fileBrowse As New System.Windows.Forms.OpenFileDialog()
'Note that all this Save dialog stuff is optional, but it is nicer than just an InputBox in many cases.
fileBrowse.AddExtension = True
fileBrowse.DefaultExt = ".txt"
fileBrowse.ValidateNames = True
fileBrowse.OverwritePrompt = True
fileBrowse.FileName = "File1.txt"
fileBrowse.InitialDirectory = _
System.Environment.GetFolderPath(Environment.SpecialFolder.Personal)
fileBrowse.RestoreDirectory = True
fileBrowse.Title = "Please Enter a File Name To Save Under"
fileBrowse.ShowDialog()
sFileName = fileBrowse.FileName
Dim myNewFile As New System.IO.StreamWriter(sFileName, False)
myNewFile.WriteLine("-- New fileName--")
myNewFile.Close()
本文来自博客园,作者:Slashout,转载请注明原文链接:https://www.cnblogs.com/SlashOut/archive/2006/04/03/365800.html