"Given path's format is not supported"

ramone

Active member
Joined
Sep 29, 2005
Messages
26
hello
i want to copy an ms access database file (.mdb) from a dir to another, simple, but my program throws an excpetion NotSupportedException saying "Given paths format is not supported", how can i copy my file??, heres my code:

[VB]
Dim path As String = ""
target filename will contain todays date
Dim hoy As String = Today.ToString
hoy = hoy.Replace("\", "-")

Dim path1 As String = selPath.SelectedPath + "\udm_" + hoy + "_"
Dim ext As String = ".mdb"
Dim num As Integer = 1
generate target path
path = path1 + num.ToString + ext
check if not exists, else increment the number
While File.Exists(path)
num = num + 1
path = path1 + num.ToString + ext
End While

Dim source As String = Me.path + "db\db.mdb"

exception thrown around the next lines
Dim fs As FileStream = File.Create(path)
fs.Close()
File.Copy(source, path)
[/VB]

thanks for your help
 
To combine paths you should use Path.Combine(). You arent checking the path length so see if it exceeds the limit of length, you arent checking for invalid characters, you arent checking that the destination directory exists. If it ever worked itd be through luck not skill.
You need to validate your data. I think youre probably ending up with an illegal character from the date.ToString() but youll find that out for yourself when you step through it.
 
Back
Top