U cemu je problem? On bi treba recimo, ako imam folder Test, da skonta e, postoji taj folder, hoces da sacuvas oba, ako da, on treba da sacuva Test (1).
Sa fajlovima mi sve funkcionise, ali sa folderom ne, u cemu je problem, tj gde je u kodu?
Code:
If System.IO.Directory.Exists(destinationFolderPath) Then
Dim nextAvialableFolderPath As String = GetDestinationFolderPath(txtFolderNetworkPath.Text, System.IO.Path.GetDirectoryName(originalFolderPath))
Select Case MessageBox.Show("Fajl vec postoji. Hoces li da zamenis(yes) ili da sacuvas oba (no) ili da prekines operaciju (Close)", "Greska", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)
Case Windows.Forms.DialogResult.No
My.Computer.FileSystem.CopyDirectory(originalFolderPath, nextAvialableFolderPath)
If System.IO.Directory.Exists(destinationFolderPath) Then
Dim nextAvialableFolderPath As String = GetDestinationFolderPath(txtFolderNetworkPath.Text, System.IO.Path.GetDirectoryName(originalFolderPath))
Select Case MessageBox.Show("Fajl vec postoji. Hoces li da zamenis(yes) ili da sacuvas oba (no) ili da prekines operaciju (Close)", "Greska", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)
Case Windows.Forms.DialogResult.No
My.Computer.FileSystem.CopyDirectory(originalFolderPath, nextAvialableFolderPath)
a evo i funkcije
Code:
Private Function GetDestinationFolderPath(location As String, folderName As String)
Dim counter As Integer = 0
Dim desiredFolderPath As String = System.IO.Path.Combine(location, String.Format("{0}", folderName))
While System.IO.Directory.Exists(desiredFolderPath)
counter += 1
desiredFolderPath = System.IO.Path.Combine(location, String.Format("{0} ({1})", folderName, counter.ToString))
End While
Return desiredFolderPath
End Function
Private Function GetDestinationFolderPath(location As String, folderName As String)
Dim counter As Integer = 0
Dim desiredFolderPath As String = System.IO.Path.Combine(location, String.Format("{0}", folderName))
While System.IO.Directory.Exists(desiredFolderPath)
counter += 1
desiredFolderPath = System.IO.Path.Combine(location, String.Format("{0} ({1})", folderName, counter.ToString))
End While
Return desiredFolderPath
End Function