vb.net文件夹上传,net 文件上传

vb.net d盘有个文件夹file里面有excel类型文件怎么用getfile取到文件的路径

你好,请使用System.IO.Directory.EnumerateFiles()方法

创新互联专注于企业全网营销推广、网站重做改版、清河网站定制设计、自适应品牌网站建设、H5开发商城系统网站开发、集团公司官网建设、成都外贸网站制作、高端网站制作、响应式网页设计等建站业务,价格优惠性价比高,为清河等各大城市提供网站开发制作服务。

Dim XLS文件列表 As IEnumerable(Of string)

Dim XLSX文件列表 As IEnumerable(Of string)

Dim path As String = "D:\File\"

XLS文件列表 = Directory.EnumerateFiles(path, "*.xls", SearchOption.TopDirectoryOnly)

XLSX文件列表 = Directory.EnumerateFiles(path, "*.xlsx", SearchOption.TopDirectoryOnly)

vb.net中,读取和写入文件

写入:Dim sr As New IO.StreamWriter(Application.StartupPath "/写入的文本.txt")

sr.WriteLine("写入的内容") sr.Close()读取:If (File.Exists(Application.StartupPath "/msg.txt")) Then

Dim fm As New IO.FileStream(Application.StartupPath "/读取的文本.txt", FileMode.Open)

Dim sr As IO.StreamReader = New IO.StreamReader(fm)

Do While sr.Peek() = 0

TextBox1.Text = sr.ReadLine() (读取文本到文本框)

Loop end if

vb.net 操作文件夹用户权限

'

' 需要添加以下命名空间:

' Imports System.IO

' Imports System.Security.AccessControl

' */

Dim sPath As String = Server.MapPath(文件夹名称字符串)

Directory.CreateDirectory(sPath)

addpathPower(sPath, "ASPNET", "FullControl")

'////////////////////////////////////////////////

Public Sub addpathPower(ByVal pathname As String, ByVal username As String, ByVal power As String)

Dim dirinfo As DirectoryInfo = New DirectoryInfo(pathname)

If (dirinfo.Attributes FileAttributes.ReadOnly) 0 Then

dirinfo.Attributes = FileAttributes.Normal

End If

'取得访问控制列表

Dim dirsecurity As DirectorySecurity = dirinfo.GetAccessControl()

Select Case power

Case "FullControl"

dirsecurity.AddAccessRule(New FileSystemAccessRule(uername,FileSystemRights.FullControl,InheritanceFlags.ContainerInherit,PropagationFlags.InheritOnly,AccessControlType.Allow))

Exit Sub

Case "ReadOnly"

dirsecurity.AddAccessRule(New FileSystemAccessRule(username,FileSystemRights.Read,AccessControlType.Allow))

Exit Sub

Case "Write"

dirsecurity.AddAccessRule(New FileSystemAccessRule(username,FileSystemRights.Write,AccessControlType.Allow))

Exit Sub

Case "Modify"

dirsecurity.AddAccessRule(New FileSystemAccessRule(username,FileSystemRights.Modify,AccessControlType.Allow))

Exit Sub

End Select

dirinfo.SetAccessControl(dirsecurity)

End Sub

VB.net怎么弹出文件夹路径选择框

选择文件夹  在工具箱 - 对话框 里选择 FolderBrowserDialog 添加 到设计器中

然后 代码写在  按钮事件里

FolderBrowserDialog1.ShowDialog()

textbox1.text =FolderBrowserDialog1.SelectedPath

选择文件 在工具箱 - 对话框 里选择 OpenFileDialog

把 OpenFileDialog1.ShowDialog()

TextBox1.Text = OpenFileDialog1.FileName

写到按钮事件下

如图

点击按钮会弹出 通用对话框  选择好路径后 确定 ,编辑框里就会显示选择的路径


分享名称:vb.net文件夹上传,net 文件上传
网站地址:http://scyanting.com/article/hdghco.html