Saturday, August 24, 2013

How to copy directory using VB.Net



Forder to folder copy :


Dim newWfFilePath As String = Web.HttpContext.Current.Server.MapPath(filepath)
Dim defaultPath As String = Web.HttpContext.Current.Server.MapPath(copyfrom)
Dim directorys() As String = Directory.GetDirectories(defaultPath)
               
For Each folder As String In directorys
          Dim folderName() As String = folder.Split("\"c)
          Dim directoryName As String = folderName(folderName.Length - 1)
 If (Directory.Exists(newWfFilePath + "/" + directoryName)) Then
 Else
     Directory.CreateDirectory(newWfFilePath + "/" + directoryName)
     Dim strFiles() As String = Directory.GetFiles(defaultPath + "/" + directoryName)


     For Each strFile As String In strFiles
          Dim FileName() As String = strFile.Split("\"c)
          System.IO.File.Copy(strFile, newWfFilePath + "/" + directoryName +  
                              "/"+FileName(FileName.Length - 1))

     Next

 End If
Next

SQL Optimization

  SQL Optimization  1. Add where on your query  2. If you remove some data after the data return then remove the remove condition in the sel...