Moving Selected Files from one directory to anothe

Results 1 to 3 of 3

Thread: Moving Selected Files from one directory to anothe

  1. #1
    Join Date
    Dec 1969

    Default Moving Selected Files from one directory to anothe

    Currently I have a Datagrid That displays a list of files in a directory.<BR><BR>The code I used to do this is as follows:<BR><BR> Dim fi As System.IO.FileInfo<BR> Dim di As New System.IO.DirectoryInfo("//c/HayesProj")<BR> Dim files As System.IO.FileInfo() = di.GetFiles("*.pdf")<BR><BR> Dim afile As System.IO.FileInfo<BR><BR><BR> Me.Datagrid3.DataSource = files<BR><BR> Me.DataBind()<BR> <BR>Using a Template COlumn I have displayed a checkbox against each file that lists out in the datagrid. <BR><BR>How can I allow a user to select the check box against certain files in the list and then for those files with their check boxes selected have a seperate button that will move those files selected across from the source directory to the new destination directory. <BR><BR>Currently to move all the files from the source directory to the destination directory I am using the following code:<BR><BR> Dim TheFile As System.IO.FileInfo<BR> Dim TheDir As New System.IO.DirectoryInfo("//c/HayesProj")<BR> Dim AllFiles As System.IO.FileInfo() = TheDir.GetFiles("*.pdf")<BR> <BR> Dim afile As System.IO.FileInfo<BR><BR> For Each afile In AllFiles<BR> Dim newfname As String = "//d/ProjLogHistory" & "/" & afile.Name<BR> afile.MoveTo(newfname)<BR> Next<BR><BR><BR>So how can I get to move only the files that have their Check Box selected?<BR><BR>I hope someone understands what I am looking for and will be able to help.<BR><BR>Many thanks<BR>aVBlearner

  2. #2
    Join Date
    Dec 1969

    Default Try ASP.NET forum (eop)


  3. #3
    Join Date
    Dec 1969

    Default RE: Moving Selected Files from one directory to an

    Something like this in the onclick event of your button.<BR><BR>Dim myDataGridItem As DataGridItem<BR> Dim chkSelected As System.Web.UI.WebControls.CheckBox<BR> Dim strStoreName As String<BR> Dim strStoreID As String<BR><BR> For Each myDataGridItem In DG_CheckBox.Items<BR><BR> chkSelected = myDataGridItem.FindControl("chkSelection")<BR> If chkSelected.Checked Then<BR> strFile = CType(myDataGridItem.FindControl("lblFile"), Label).Text<BR><BR> &#039;code to move your file.<BR> End If<BR><BR> Next

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts