ramone Posted October 8, 2005 Posted October 8, 2005 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 path's format is not supported", how can i copy my file??, here's my code: Dim path As String = "" 'target filename will contain today's 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) thanks for your help Quote
Wraith Posted October 8, 2005 Posted October 8, 2005 To combine paths you should use Path.Combine(). You aren't checking the path length so see if it exceeds the limit of length, you aren't checking for invalid characters, you aren't checking that the destination directory exists. If it ever worked it'd be through luck not skill. You need to validate your data. I think you're probably ending up with an illegal character from the date.ToString() but you'll find that out for yourself when you step through it. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.