我有以下工作正常:
Function DirSearch(ByVal sDir As String) As String
For Each d As String In Directory.GetDirectories(sDir)
For Each f As String In Directory.GetFiles(d)
objSQLStringBuilder.Append("insert into table1 (full_path, file_name) values ('" & "file:///" + f.Replace("'", "''").Replace(" ", "%20").Replace("\", "/") & "', '" & f.Remove(0, Len(d) + 1).Replace("'", "''") & "');")
Next
DirSearch(d)
Next
Return objSQLStringBuilder.ToString
End Function
我如何将其更改为使用UNC而不是本地目录映射?
例如,如果我将sDir
设置为C:\
,则代码可以正常工作。我需要做些什么改变才能使用\\server\c$\
代替它?
答案 0 :(得分:1)
好,所以你知道要返回path
shared folder
dim myLocalpath as string = "c:\"
dim mysharedpath as string = "\\" & Environment.MachineName & "\" & myLocalpath
Consloe.Writeline(mysharedpath)
Output:
\\server\c:\