none
class to copy contents of one directory to another with progress bar RRS feed

  • Question

  • Hi

    I am simply trying to copy contents of source folder to a destination folder including all files and sub folders

    I have tried using System.IO but keep getting errors about permissions even though app running as admin and I have all permissions

    Also tried file.copyto but with similar issues

    And finally below so it shows windows ui for progress, but this acts odd and finds more files in source than actually exist?

     My.Computer.FileSystem.CopyDirectory(TemporaryInstallWimMountPath & "\Windows", ExtractedInstallWimPath, FileIO.UIOption.AllDialogs, FileIO.UICancelOption.ThrowException)


    Darren Rose


    • Edited by wingers Monday, December 25, 2017 10:35 PM
    Saturday, December 23, 2017 8:55 PM

All replies

  • Hi

    What are the values for the source and destination in your code line?


    Regards Les, Livingston, Scotland

    Saturday, December 23, 2017 10:05 PM
  • source = c:\users\darren\appdata\local\temp\mount

    destination = d:\test\extractedfiles


    Darren Rose

    Saturday, December 23, 2017 10:11 PM
  • Hi

    I created the paths as per your example, and all worked OK. I did not encounter an Access Denied issue.

    Here is the code I tested with.

    Try
       My.Computer.FileSystem.CopyDirectory("C:\Users\lesha\AppData\Local\Temp\mount", "C:\Test\extractedfiles", FileIO.UIOption.AllDialogs, FileIO.UICancelOption.ThrowException)
    Catch ex As Exception
       Stop
    End Try


    Regards Les, Livingston, Scotland

    Saturday, December 23, 2017 11:07 PM
  • Hi, just tried it again here and fails every time. I suspect it is something to do with the source files in the source directory which is basically an install.wim mounted using DISM

    Darren Rose

    Saturday, December 23, 2017 11:42 PM
  • Darren,

    I'd use System.IO but there's nothing wrong with using My.Computer.FileSystem.

    If you were to create a class with a lot of methods (each which used System.IO) then you now know what My.Computer.FileSystem is and does. It's convenient and if you like the default progress (as Les has shown) then you have it all. :)

    *****

    If you want something that's more custom though, you need to get back to System.IO. I'll add this: Don't create your own file paths with concatenation; use System.IO.Path.Combine for that. It was created for exactly that purpose.

    Lastly is this: If you have any structured exception handling (Try/Catch) then at this stage, either remove those or comment them out. You need to see what exception is being thrown and why. If it throws an exception, dig into the stack trace - that should eventually tell you where and from that, you can then derive the "why".


    "A problem well stated is a problem half solved.” - Charles F. Kettering


    • Edited by Frank L. Smith Saturday, December 23, 2017 11:49 PM ...typo
    Saturday, December 23, 2017 11:47 PM
  • And finally below so it shows windows ui for progress, but this acts odd and finds more files in source than actually exist?
     My.Computer.FileSystem.CopyDirectory(TemporaryInstallWimMountPath & "\Windows", ExtractedInstallWimPath, FileIO.UIOption.AllDialogs, FileIO.UICancelOption.ThrowException)


    Darren Rose

     This method will copy files with system and hidden attributes too.  That would be the only way i see it coming up with more files than you see there or think are there.

      If you are looking at the folder properties to get this information,  they don't always match.  I believe the OS filters out hidden system files or some combination of them in the properties information.  I have run into this mismatch before and never did figured out exactly why the folder properties did not match the sizes and counts i was coming up with.


    If you say it can`t be done then i`ll try it

    Saturday, December 23, 2017 11:55 PM
  • @ Frank

    Thanks for reply

    I believe issue in this case must be permissions on my "source" files as whatever method I use I get errors, so need to spend more time with it

    In this app I have several areas where I will need to copy some files/folders from A to B, so was hoping to create some sort of simple class or function that I can pass source and destination to and it then does it and updates a progress bar as it runs, then I can use it for multiple different uses

    Would rather have my own progress showing - rather than the default windows GUI popping up

    Point taken re try..catch, will play more tomorrow with it


    Darren Rose

    Sunday, December 24, 2017 12:12 AM
  • @IronRazerz

    Yes it is very odd, as I checked with all hidden/system showing, and checked from command line - for some reason it was coming up with much larger size during the copy process and kept "discovering" for ages with file size and count going up 4 times what I knew was in the source location


    Darren Rose

    Sunday, December 24, 2017 12:14 AM
  • I believe issue in this case must be permissions on my "source" files as whatever method I use I get errors, so need to spend more time with it...

    Tomorrow, look at the stack trace (but do remember that it's a stack, so it's last-in, first-out).

    Challenge it manually - let's see what's going on.

    ***** EDIT *****

    One more thing to add here: Make sure that none of the source files are changing while this is going on. Obviously that can't work.


    "A problem well stated is a problem half solved.” - Charles F. Kettering


    Sunday, December 24, 2017 12:18 AM
  •   Why are you copying the files in the mounted image folder to another folder anyways?  Normally you would mount the image to a "Mount" folder,  edit the files, delete unwanted files/drivers,  add new files/drivers,  and then commit the changes back to the .wim image file.  Then you would copy the .wim file to wherever you need it and apply the image. There is no doubt that you can copy the .wim file but,  the mounted files might be protected in some way.

    If you say it can`t be done then i`ll try it

    Sunday, December 24, 2017 12:54 AM
  • PS - I forgot to mention...

     Have you tried mounting the files to a directory like "C:\Mount" and then copying them?  Just wondering if having them mounted in such a deep directory,  maybe you are hitting directories in the mounted image files that may have paths that are too long.  Not sure but,  figured i would suggest it.


    If you say it can`t be done then i`ll try it

    • Edited by IronRazerz Sunday, December 24, 2017 1:08 AM
    Sunday, December 24, 2017 1:07 AM
  •   Why are you copying the files in the mounted image folder to another folder anyways?  Normally you would mount the image to a "Mount" folder,  edit the files, delete unwanted files/drivers,  add new files/drivers,  and then commit the changes back to the .wim image file.  Then you would copy the .wim file to wherever you need it and apply the image. There is no doubt that you can copy the .wim file but,  the mounted files might be protected in some way.

    If you say it can`t be done then i`ll try it


    I was doing that as the wim I am mounting is needed for my PE builder tool, and mounting it each time takes a while, so had option of extracting files from it to a temp folder so that future builds were quicker

    Darren Rose

    Sunday, December 24, 2017 1:26 AM
  • PS - I forgot to mention...

     Have you tried mounting the files to a directory like "C:\Mount" and then copying them?  Just wondering if having them mounted in such a deep directory,  maybe you are hitting directories in the mounted image files that may have paths that are too long.  Not sure but,  figured i would suggest it.


    If you say it can`t be done then i`ll try it


    that is a good point - will give it a try tomorrow

    Darren Rose

    Sunday, December 24, 2017 1:26 AM
  • Hi all

    1) Tried mounting to different place as per IR suggestion to make sure problem wasn't paths too long - still same issue

    2) Size discrepancy is indeed down to hidden/system files - so windows properties showing me different values than the copy process did - so not an issue now

    3) Tried file copy again using command below, and yes it does seem to be a permissions issue - as per screenshots, despite app running as admin

     My.Computer.FileSystem.CopyDirectory("C:\TempMount2", "D:\a\source", FileIO.UIOption.AllDialogs, FileIO.UICancelOption.ThrowException)

    BUT if I manually perform the exact same copy then it works perfectly fine in Windows??


    Darren Rose

    Sunday, December 24, 2017 7:16 PM
  • I just posted a reply and now it's not showing up.

    I'll go back to my original suggestion though: Use System.IO.


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Sunday, December 24, 2017 7:50 PM
  • Darren,

    I tried a test. Of course I don't have an O/S that would cause permissions problems but this worked:

    Public Class Form1
        Private Sub _
            Form1_Load(sender As System.Object, _
                       e As System.EventArgs) _
                       Handles MyBase.Load
    
            Const sourceDirectory As String = "K:\Personal Folders\Tim"
    
            Const targetDirectory As String = "X:\Test Program Results"
    
            My.Computer.FileSystem.CopyDirectory(sourceDirectory, targetDirectory, _
                                                 FileIO.UIOption.AllDialogs, _
                                                 FileIO.UICancelOption.ThrowException)
    
            Stop
    
        End Sub
    End Class

    Is there anything special or different with your source and/or target directories?


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Sunday, December 24, 2017 8:05 PM
  • Darren,

    I tried a test. Of course I don't have an O/S that would cause permissions problems but this worked:

    Public Class Form1
        Private Sub _
            Form1_Load(sender As System.Object, _
                       e As System.EventArgs) _
                       Handles MyBase.Load
    
            Const sourceDirectory As String = "K:\Personal Folders\Tim"
    
            Const targetDirectory As String = "X:\Test Program Results"
    
            My.Computer.FileSystem.CopyDirectory(sourceDirectory, targetDirectory, _
                                                 FileIO.UIOption.AllDialogs, _
                                                 FileIO.UICancelOption.ThrowException)
    
            Stop
    
        End Sub
    End Class

    Is there anything special or different with your source and/or target directories?


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    So using exactly same method as me then - so it must be to do with my files and permissions then

    The files are mounted from a windows image .wim file using DISM - so must be permissions related


    Darren Rose

    Sunday, December 24, 2017 8:08 PM
  • I just posted a reply and now it's not showing up.

    I'll go back to my original suggestion though: Use System.IO.


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Happy to try system.io, but would still need a way to show progress

    Am now looking at just copying the few files I need from the source mounted WIM file, rather than the whole lot, which may work better, and may help avoid the permissions issue hopefully

    But even for this (and a later task to copy files to USB) I would need a simple class or function that I can pass source and destination and then it copies with a progress bar indicating progress etc


    Darren Rose

    Sunday, December 24, 2017 8:09 PM

  • So using exactly same method as me then - so it must be to do with my files and permissions then

    The files are mounted from a windows image .wim file using DISM - so must be permissions related


    Darren Rose

    If it were permissions, you'd run into the same issue when you tried manually, no?


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Sunday, December 24, 2017 8:14 PM
  • If it were permissions, you'd run into the same issue when you tried manually, no?


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Well yes that was exactly my thought - but using that method is showing the exact same windows file copy GUI as I get when doing it manually, so I am at a loss as to why works manually in windows and not through my app running with admin permissions

    Very odd...


    Darren Rose

    Sunday, December 24, 2017 8:26 PM

  • Well yes that was exactly my thought - but using that method is showing the exact same windows file copy GUI as I get when doing it manually, so I am at a loss as to why works manually in windows and not through my app running with admin permissions

    Very odd...


    Darren Rose

    I don't know either. I'm at a loss on this one.

    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Sunday, December 24, 2017 8:29 PM
  • Okay, I have had a play about copying parts of the source using VB and some copies fine, other bits come up with permission errors

    So I have amended the copy to just get bits I need and luckily all of these seem to copy okay without any permission issues

    Therefore all I need to do now is come up with some class or similar to do the file copy part for me and show a progress bar based on say size or number of files to copy - as I really want to have the progress integrated in my app rather than the windows file copy dialog popping up


    Darren Rose

    Sunday, December 24, 2017 8:39 PM
  • Therefore all I need to do now is come up with some class or similar to do the file copy part for me and show a progress bar based on say size or number of files to copy - as I really want to have the progress integrated in my app rather than the windows file copy dialog popping up


    Darren Rose

    Go back a year then - that's what we did about this time last year and I showed progress on a "per byte" basis.

    *****

    Why can't you copy the other ones?

    Are they protected? Are they changing as you're trying to copy them?


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Sunday, December 24, 2017 8:42 PM
  • Yes I had thought that - but I wanted a small/simple method to use for this (and other uses) if possible, as that previous project was a much more complex and robust solution which was perfect for a backup tool and the ability to add lots of different sources, options etc - but probably overkill for this requirement

    ***

    I don't know, other than error screenshots already shown which would indicate some sort of protection, but then why can I then copy them manually

    No they are definitely not changing as I am trying to copy them


    Darren Rose

    Sunday, December 24, 2017 8:50 PM
  • Yes I had thought that - but I wanted a small/simple method to use for this (and other uses) if possible, as that previous project was a much more complex and robust solution which was perfect for a backup tool and the ability to add lots of different sources, options etc - but probably overkill for this requirement

    ***

    I don't know, other than error screenshots already shown which would indicate some sort of protection, but then why can I then copy them manually

    No they are definitely not changing as I am trying to copy them


    Darren Rose

    I don't know. I think you need to work through the issue of not being able to copy what you want.

    As for the other, it can be made to work (to show progress). In the following I'm showing that I don't know how to make the production work like I want but here it is anyway:

    http://www.fls-online.net/VBNet_Forum/Copier_Progress/Copier_Progress.html


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Sunday, December 24, 2017 9:14 PM
  • I think it is because the files originate from a windows image backup (.wim file) so have all the associated permissions that a standard Windows install would have, which is why they don't seem to like being copied using VB

    As it happens I really don't need them all anyway, just a small subset of them which do copy okay so that will be fine for what I am doing

    Yes I like how that can show progress

    As I say my needs for this are very basic, the amount of files to copy and the size is reasonably small - no more than say 100 files and maximum of 1Gb so really just something to indicate to the user that files are copying and roughly how much completed etc


    Darren Rose

    Sunday, December 24, 2017 9:19 PM
  • I think it is because the files originate from a windows image backup (.wim file) so have all the associated permissions that a standard Windows install would have, which is why they don't seem to like being copied using VB

    As it happens I really don't need them all anyway, just a small subset of them which do copy okay so that will be fine for what I am doing

    Yes I like how that can show progress

    As I say my needs for this are very basic, the amount of files to copy and the size is reasonably small - no more than say 100 files and maximum of 1Gb so really just something to indicate to the user that files are copying and roughly how much completed etc


    Darren Rose


    Well let's see what other have to say here, but with System.IO you control everything (that's what you saw there).

    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Sunday, December 24, 2017 9:24 PM
  • As I say my needs for this are very basic, the amount of files to copy and the size is reasonably small - no more than say 100 files and maximum of 1Gb so really just something to indicate to the user that files are copying and roughly how much completed etc

    Darren Rose

    Hi

    Here is some code, using a BackGroundWorker to keep UI responsive, that uses a Filter to only copy files of particular types (Filter). There is a variable for OverWrite also.

    Maybe of some help.

    ' Form1 with ProgressBar1, Label1
    ' and Button1
    Option Strict On
    Option Explicit On
    Imports System.ComponentModel
    Public Class Form1
      Dim src, dest, filter() As String
    
      ' overwrite set to True
      ' if set to False then error
      ' handling will be needed
      Dim Overwrite As Boolean = True
      Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    	Button1.Text = "START"
    
    	' src, dest & filter could be from
    	' TextBoxes perhaps
    	src = "C:\Users\lesha\Desktop\Plans\New folder\TestRTF"
    	dest = "C:\Users\lesha\Desktop\Plans\New folder\Test2RTF"
    	filter = {"*.txt", "*.rtf"}
    
      End Sub
    
      Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    	Dim b As Button = DirectCast(sender, Button)
    	Select Case b.Text
    	  Case "START"
    		b.Text = "CANCEL"
    		If Not IO.Directory.Exists(dest) Then IO.Directory.CreateDirectory(dest)
    		If Not BackgroundWorker1.IsBusy Then
    		  ProgressBar1.Value = 0
    		  BackgroundWorker1.RunWorkerAsync()
    		End If
    	  Case Else
    		BackgroundWorker1.CancelAsync()
    		b.Text = "START"
    	End Select
      End Sub
    
      Public Delegate Sub PBmax(ByVal value As Integer)
      Private Sub SetPBMax(v As Integer)
    	ProgressBar1.Maximum = v
      End Sub
      Private Sub BackgroundWorker1_DoWork(sender As Object, e As DoWorkEventArgs) Handles BackgroundWorker1.DoWork
    	Dim worker As BackgroundWorker = CType(sender, BackgroundWorker)
    
    	Dim fs() As String = My.Computer.FileSystem.GetFiles(src,
    	FileIO.SearchOption.SearchTopLevelOnly, filter).ToArray
    
    	Invoke(New PBmax(AddressOf SetPBMax), fs.Count)
    
    
    	Dim c As Integer = 1
    	For Each s As String In fs
    	  If worker.CancellationPending Then
    		e.Cancel = True
    		Exit For
    	  End If
    	  Try
    		IO.File.Copy(s, IO.Path.Combine(dest, IO.Path.GetFileName(s)), Overwrite)
    		worker.ReportProgress(c)
    		c += 1
    	  Catch ex As IO.IOException
    		' need exception handling
    		' for this example, just ignore
    		' if OverWrite set to False and
    		' exception is 'Already Exists"
    		If Not Overwrite AndAlso ex.Message.ToLower.Contains("already exist") Then
    		  ' ignore
    		Else
    		  MessageBox.Show("ERROR: " & ex.Message)
    		  e.Cancel = True
    		End If
    	  End Try
    
    	  ' this is ONLY for testing
    	  ' remove if code is actually used.
    	  Threading.Thread.Sleep(100)
    
    	Next
      End Sub
    
      Private Sub BackgroundWorker1_ProgressChanged(sender As Object, e As ProgressChangedEventArgs) Handles BackgroundWorker1.ProgressChanged
    	ProgressBar1.Value = e.ProgressPercentage
    	Label1.Text = "Copied " & e.ProgressPercentage.ToString & " of " & ProgressBar1.Maximum.ToString & " files."
      End Sub
      Private Sub BackgroundWorker1_RunWorkerCompleted(sender As Object, e As RunWorkerCompletedEventArgs) Handles BackgroundWorker1.RunWorkerCompleted
    	Button1.Text = "START"
    	Label1.Text &= " CANCELLED or FINISHED"
      End Sub
    End Class


    Regards Les, Livingston, Scotland

    Sunday, December 24, 2017 11:27 PM
  • Well let's see what other have to say here, but with System.IO you control everything (that's what you saw there).


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Okay thanks Frank, will look in to it

    Thanks for replying and have a great Christmas


    Darren Rose

    Monday, December 25, 2017 12:34 AM
  • @Leshay

    Thanks for that, will look more in next few days

    Have a great Christmas


    Darren Rose

    Monday, December 25, 2017 12:35 AM

  • Okay thanks Frank, will look in to it

    Thanks for replying and have a great Christmas


    Darren Rose

    You also. :)

    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Monday, December 25, 2017 12:38 AM
  • @Leshay

    Thanks for that, will look more in next few days

    Have a great Christmas


    Darren Rose

    Hi wingers and Frank

    Have a good Christmas time, and have a prosperous New Year.


    Regards Les, Livingston, Scotland

    Monday, December 25, 2017 12:44 AM
  • @Leshay

    Thanks for that, will look more in next few days

    Have a great Christmas


    Darren Rose

    Hi wingers and Frank

    Have a good Christmas time, and have a prosperous New Year.


    Regards Les, Livingston, Scotland


    ... and to you also Les! :)

    "A problem well stated is a problem half solved.” - Charles F. Kettering


    Monday, December 25, 2017 12:51 AM
  • I suggest that you try LongPathTool.

    Hello Richard,

    The question at hand has to do with coding, not a third party tool so please keep your responses to solutions that have to do with coding in VB.NET programming language.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Monday, December 25, 2017 5:34 PM
    Moderator

  • Okay thanks Frank, will look in to it

    Thanks for replying and have a great Christmas


    Darren Rose

    Darren,

    When you get back to this, give this a try:

    {Link Removed}

    I put it together somewhat quickly and I know I don't have any options there (I will eventually).

    When you start it though, choose the source and target directories then it's just a matter of waiting until it's done:

    Let me know how that works on your end please?

    Also: The first screenshot was done before I made some changes; the GroupControl isn't disabled now.


    "A problem well stated is a problem half solved.” - Charles F. Kettering


    Monday, December 25, 2017 7:13 PM
  • Okay on first run I got this error:-

    So I then right clicked and ran as administrator and I get this error:-


    Darren Rose

    Monday, December 25, 2017 7:26 PM
  • Okay on first run I got this error:-

    So I then right clicked and ran as administrator and I get this error:-


    Darren Rose

    I intentionally left out any safeguards - but the issue is that "Program Files" looks to be a protected directory.

    - BUT -

    Why aren't you getting that doing it manually? I don't know.

    It's an odd one, if nothing else, it's that. Did you try what Les showed?


    "A problem well stated is a problem half solved.” - Charles F. Kettering


    Monday, December 25, 2017 7:32 PM
  • Okay, I have had a play about copying parts of the source using VB and some copies fine, other bits come up with permission errors

    So I have amended the copy to just get bits I need and luckily all of these seem to copy okay without any permission issues

    Therefore all I need to do now is come up with some class or similar to do the file copy part for me and show a progress bar based on say size or number of files to copy - as I really want to have the progress integrated in my app rather than the windows file copy dialog popping up


    Darren Rose

    For each file, before you copy, consider something like this:

        Private Function Is_File_Locked(strFileName As String) As Boolean
            Try
                Using FS As IO.FileStream = IO.File.Open(strFileName, IO.FileMode.Open, IO.FileAccess.ReadWrite, IO.FileShare.ReadWrite)
                    Return False ' file is not locked
                End Using
    
            Catch AD As System.UnauthorizedAccessException
                Return True
            Catch exIO As System.IO.IOException
                Return True
            Catch ex As Exception
                Return True
            End Try
        End Function
    
    If it returns True, don't try to copy the file, perhaps save the filename in a list for later inspection. 

    Monday, December 25, 2017 7:42 PM
  • I intentionally left out any safeguards - but the issue is that "Program Files" looks to be a protected directory.

    - BUT -

    Why aren't you getting that doing it manually? I don't know.

    It's an odd one, if nothing else, it's that. Did you try what Les showed?


    "A problem well stated is a problem half solved.” - Charles F. Kettering


    Yes just tried Les's example and same problem

    System.UnauthorizedAccessException:

    'Access to the path 'C:\tempmount2\ProgramData\Microsoft\Windows Defender Advanced Threat Protection\Cache' is denied.'


    Darren Rose

    Monday, December 25, 2017 7:43 PM

  • Yes just tried Les's example and same problem

    System.UnauthorizedAccessException:

    'Access to the path 'C:\tempmount2\ProgramData\Microsoft\Windows Defender Advanced Threat Protection\Cache' is denied.'


    Darren Rose

    I fold. ;-)

    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Monday, December 25, 2017 7:45 PM
  • I intentionally left out any safeguards - but the issue is that "Program Files" looks to be a protected directory.

    - BUT -

    Why aren't you getting that doing it manually? I don't know.

    It's an odd one, if nothing else, it's that. Did you try what Les showed?


    "A problem well stated is a problem half solved.” - Charles F. Kettering


    Yes just tried Les's example and same problem

    System.UnauthorizedAccessException:

    'Access to the path 'C:\tempmount2\ProgramData\Microsoft\Windows Defender Advanced Threat Protection\Cache' is denied.'


    Darren Rose

    Hi

    Not surprised, and glad that access was denied in a way as system files are carefully protected. Just imagine if some malware had easy access to system files like that.

    Why do you want to work with those files I thought you were talking about only wanting to work with the file types that were not system protected.

    As a test, can you try (any of the code contributions) with files known to be non-system to see if they can be copied.


    Regards Les, Livingston, Scotland

    Monday, December 25, 2017 7:55 PM
  • I fold. ;-)


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Fair enough

    Anyway I have solved the issue of needing to copy all those files anyway, instead I now just copy the ones I want which happen to all be ones which are not protected - so permissions problem is solved

    But still just need a basic method of supplying source and destination and it copying with progress bar - like you test app does


    Darren Rose

    Monday, December 25, 2017 7:57 PM
  • Hi

    Not surprised, and glad that access was denied in a way as system files are carefully protected. Just imagine if some malware had easy access to system files like that.

    Why do you want to work with those files I thought you were talking about only wanting to work with the file types that were not system protected.

    As a test, can you try (any of the code contributions) with files known to be non-system to see if they can be copied.


    Regards Les, Livingston, Scotland

    No I am not surprised and totally understand and expect them to be protected system files - but why can I manually copy them but an app can't as app runs as administrator anyway so should have same permissions as me being logged on as admin

    The folder in question as previously mentioned is contents of WIM image file extracted

    Works fine with non- system and I can just copy files I need rather than ALL of them which gets round permission problem


    Darren Rose

    Monday, December 25, 2017 7:59 PM
  • ... but why can I manually copy them but an app can't as app runs as administrator anyway so should have same permissions as me being logged on as admin

    The folder in question as previously mentioned is contents of WIM image file extracted

    Works fine with non- system and I can just copy files I need rather than ALL of them which gets round permission problem


    Darren Rose

    I agree - it seems to me that it should be the same both ways.

    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Monday, December 25, 2017 8:01 PM
  • Works fine with non- system and I can just copy files I need rather than ALL of them which gets round permission problem

    Darren Rose

    Hi

    It would seem that you now have different requirements (this thread title is about Directory Copy).

    If you are going to tackle it now as file copy, and you need help with that, I suggest you start a new Thread (but leave out the 'Simple' portion of the title). If you do, then include information on how you want to deal with the required file names/types - user list etc.


    Regards Les, Livingston, Scotland

    Monday, December 25, 2017 8:36 PM
  • Hi

    It would seem that you now have different requirements (this thread title is about Directory Copy).

    If you are going to tackle it now as file copy, and you need help with that, I suggest you start a new Thread (but leave out the 'Simple' portion of the title). If you do, then include information on how you want to deal with the required file names/types - user list etc.


    Regards Les, Livingston, Scotland

    same requirement - e.g. copying a source folder to a destination folder - just different folder than before i.e. specific one I need rather than the whole lot

    Darren Rose

    Monday, December 25, 2017 10:35 PM
  • Darren,

    Bear with me a few days. I have an idea...


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Monday, December 25, 2017 11:43 PM
  • same requirement - e.g. copying a source folder to a destination folder - just different folder than before i.e. specific one I need rather than the whole lot

    Darren Rose

    Hi

    So from previous posts, I believe you are meaning to copy from a folder containing ONLY files which have no access denied exceptions - is that so?

    If so, does the code I posted work when you set the Src and Dest paths accordingly?


    Regards Les, Livingston, Scotland

    Monday, December 25, 2017 11:51 PM
  • Darren,

    Would you try this version please:

    {Link Removed}

    It looks and works the same as yesterday's version but you'll see that I've added something in.

    It's unprotected so if it's going to give you an error, you'll see the same thing as yesterday.

    Let me know please.


    "A problem well stated is a problem half solved.” - Charles F. Kettering


    Tuesday, December 26, 2017 4:06 PM
  • Hi Frank

    Initial testing:-

    scans though folders fine

    then sits for a long time just showing Please Wait with no idea if it is doing anything

    after a while it started copying files, with error below popping up regularly - although copy seems to continue in the background, and if I click continue then error comes back every time

    Have left it running to see if it completes okay


    Darren Rose

    Tuesday, December 26, 2017 4:25 PM
  • just finished

    odd results though

    • Destination has larger size than source
    • Destination has less files
    • Destination has more folders


    Darren Rose

    Tuesday, December 26, 2017 4:29 PM
  • just finished

    odd results though

    • Destination has larger size than source
    • Destination has less files
    • Destination has more folders


    Darren Rose

    Man -- I've never seen anything like that.

    It should have skipped over the files which are in protected directories and copied the rest. Your results there aren't at all what it should have done.

    I'll try it on something that I know I can't touch - and see what it comes back with.


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Tuesday, December 26, 2017 4:32 PM
  • Darren,

    I have it copying an entire drive - obviously it can't touch System Volume and a few others there, but it'll take a while.

    In the meantime, when you copy it manually, are the results anything like what you just showed above?


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Tuesday, December 26, 2017 4:49 PM
  • Okay

    When I copy it manually in explorer then the source/destinations match nearly exactly, give or take a file and a few mb


    Darren Rose

    Tuesday, December 26, 2017 4:55 PM
  • Okay

    When I copy it manually in explorer then the source/destinations match nearly exactly, give or take a file and a few mb


    Darren Rose

    As a test, would you try mine again and this next time, choose a more "normal" directory as the source?

    Mine is running but it'll take a while...


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Tuesday, December 26, 2017 5:01 PM
  • Works fine on a "normal" directory - no errors popping up, and results tally

    Darren Rose

    Tuesday, December 26, 2017 5:20 PM
  • Works fine on a "normal" directory - no errors popping up, and results tally

    Darren Rose

    At least for that.

    I'll wait to see what my results are - I'm not sure that it'll tell me anything of value, but maybe.


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Tuesday, December 26, 2017 5:21 PM
  • Works fine on a "normal" directory - no errors popping up, and results tally

    Darren Rose


    It worked to the extent that I intended it to.

    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Tuesday, December 26, 2017 6:26 PM
  • Works fine on a "normal" directory - no errors popping up, and results tally


    Darren Rose


    It worked to the extent that I intended it to.

    "A problem well stated is a problem half solved.” - Charles F. Kettering


    Okay, must be me then

    Darren Rose

    Tuesday, December 26, 2017 6:31 PM
  • Okay, must be me then

    Darren Rose

    There's something "odd" with those source files - and the results that you showed earlier make no sense at all.

    I'm stumped -- I don't know.


    "A problem well stated is a problem half solved.” - Charles F. Kettering


    Tuesday, December 26, 2017 6:36 PM
  • Okay, must be me then

    Darren Rose

    There's something "odd" with those source files - and the results that you showed earlier make no sense at all.

    I'm stumped -- I don't know.


    "A problem well stated is a problem half solved.” - Charles F. Kettering


    Same here, very odd - no obvious answer

    But I can live without copying them all, and just copy the ones I need which copy fine, and hopefully with a progress bar working so user has idea of progress


    Darren Rose

    Tuesday, December 26, 2017 6:39 PM

  • Same here, very odd - no obvious answer

    But I can live without copying them all, and just copy the ones I need which copy fine, and hopefully with a progress bar working so user has idea of progress


    Darren Rose

    The only change I made from yesterday's to today's version was that I route the source directory through something you've used many times before: I refer to it as the "John Wein" method. It tosses out any directory that throws an exception when trying to be accessed.

    The result is a list of directory paths which presumably are safe to traverse.

    *****

    As a thought here: Is it possible that a file (not the directory that it's in) might be the culprit here?

    At this stage, I don't know what I'm looking for and I have no way to test it so I have to guess.


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Tuesday, December 26, 2017 6:45 PM
  • Ah yes I remember that method from previous projects

    ***

    Yes it is possible it is a file rather than a folder I suppose, but certainly the errors yesterday seemed to indicate a folder each time rather than folder, but its definitely possible

    What was the error pop-up I kept getting about? could that be a cause of my odd results?


    Darren Rose

    Tuesday, December 26, 2017 6:49 PM

  • What was the error pop-up I kept getting about? could that be a cause of my odd results?


    Darren Rose

    I don't have a clue right now.

    Where in the process did you see that? Right now I don't know where it's coming from because I can't replicate it here.


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Tuesday, December 26, 2017 6:53 PM

  • What was the error pop-up I kept getting about? could that be a cause of my odd results?


    Darren Rose

    I don't have a clue right now.

    Where in the process did you see that? Right now I don't know where it's coming from because I can't replicate it here.


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    during the copy process, every few seconds

    Will recreate and try and show more error details, and see if that helps


    Darren Rose

    Tuesday, December 26, 2017 6:55 PM

  • Will recreate and try and show more error details, and see if that helps


    Darren Rose

    Ok

    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Tuesday, December 26, 2017 6:57 PM
  • Error comes up just after files start copying, but copy continues in background, if I click Continue on message then a few seconds later it pops up again

    Contents of the error are below

    See the end of this message for details on invoking 
    just-in-time (JIT) debugging instead of this dialog box.
    
    ************** Exception Text **************
    System.ArgumentException: Destination array was not long enough. Check destIndex and length, and the array's lower bounds.
       at System.Array.Copy(Array sourceArray, Int32 sourceIndex, Array destinationArray, Int32 destinationIndex, Int32 length, Boolean reliable)
       at StreamingFileCopier.Operations.Copier.(Object ,  )
       at ..()
       at ..(Object , EventArgs )
       at System.Windows.Forms.Timer.OnTick(EventArgs e)
       at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
    
    
    ************** Loaded Assemblies **************
    mscorlib
        Assembly Version: 4.0.0.0
        Win32 Version: 4.7.3024.0 built by: NET472REL1
        CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
    ----------------------------------------
    DirectoryCopier
        Assembly Version: 1.0.0.0
        Win32 Version: 1.0.0.0
        CodeBase: file:///C:/Users/Darren%20Rose/Downloads/DirectoryCopier_V2/DirectoryCopier.exe
    ----------------------------------------
    Microsoft.VisualBasic
        Assembly Version: 10.0.0.0
        Win32 Version: 14.7.3024.0 built by: NET472REL1
        CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/Microsoft.VisualBasic/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll
    ----------------------------------------
    System
        Assembly Version: 4.0.0.0
        Win32 Version: 4.7.3024.0 built by: NET472REL1
        CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
    ----------------------------------------
    System.Core
        Assembly Version: 4.0.0.0
        Win32 Version: 4.7.3024.0 built by: NET472REL1
        CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
    ----------------------------------------
    System.Windows.Forms
        Assembly Version: 4.0.0.0
        Win32 Version: 4.7.3024.0 built by: NET472REL1
        CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
    ----------------------------------------
    System.Drawing
        Assembly Version: 4.0.0.0
        Win32 Version: 4.7.3024.0 built by: NET472REL1
        CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
    ----------------------------------------
    System.Configuration
        Assembly Version: 4.0.0.0
        Win32 Version: 4.7.3024.0 built by: NET472REL1
        CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
    ----------------------------------------
    System.Xml
        Assembly Version: 4.0.0.0
        Win32 Version: 4.7.3024.0 built by: NET472REL1
        CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
    ----------------------------------------
    System.Runtime.Remoting
        Assembly Version: 4.0.0.0
        Win32 Version: 4.7.3024.0 built by: NET472REL1
        CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Runtime.Remoting/v4.0_4.0.0.0__b77a5c561934e089/System.Runtime.Remoting.dll
    ----------------------------------------
    DevExpress.Utils.v17.2
        Assembly Version: 17.2.4.0
        Win32 Version: 17.2.4.0
        CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/DevExpress.Utils.v17.2/v4.0_17.2.4.0__b88d1754d700e49a/DevExpress.Utils.v17.2.dll
    ----------------------------------------
    DevExpress.Data.v17.2
        Assembly Version: 17.2.4.0
        Win32 Version: 17.2.4.0
        CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/DevExpress.Data.v17.2/v4.0_17.2.4.0__b88d1754d700e49a/DevExpress.Data.v17.2.dll
    ----------------------------------------
    DevExpress.XtraEditors.v17.2
        Assembly Version: 17.2.4.0
        Win32 Version: 17.2.4.0
        CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/DevExpress.XtraEditors.v17.2/v4.0_17.2.4.0__b88d1754d700e49a/DevExpress.XtraEditors.v17.2.dll
    ----------------------------------------
    DevExpress.XtraDialogs.v17.2
        Assembly Version: 17.2.4.0
        Win32 Version: 17.2.4.0
        CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/DevExpress.XtraDialogs.v17.2/v4.0_17.2.4.0__b88d1754d700e49a/DevExpress.XtraDialogs.v17.2.dll
    ----------------------------------------
    DevExpress.XtraBars.v17.2
        Assembly Version: 17.2.4.0
        Win32 Version: 17.2.4.0
        CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/DevExpress.XtraBars.v17.2/v4.0_17.2.4.0__b88d1754d700e49a/DevExpress.XtraBars.v17.2.dll
    ----------------------------------------
    StreamingFileCopier
        Assembly Version: 1.2.0.0
        Win32 Version: 1.0.0.0
        CodeBase: file:///C:/Users/Darren%20Rose/Downloads/DirectoryCopier_V2/DirectoryCopier.exe
    ----------------------------------------
    DevExpress.BonusSkins.v17.2
        Assembly Version: 17.2.4.0
        Win32 Version: 17.2.4.0
        CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/DevExpress.BonusSkins.v17.2/v4.0_17.2.4.0__b88d1754d700e49a/DevExpress.BonusSkins.v17.2.dll
    ----------------------------------------
    UIAutomationClient
        Assembly Version: 4.0.0.0
        Win32 Version: 4.7.3024.0 built by: NET472REL1
        CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/UIAutomationClient/v4.0_4.0.0.0__31bf3856ad364e35/UIAutomationClient.dll
    ----------------------------------------
    DevExpress.Dialogs.v17.2.Core
        Assembly Version: 17.2.4.0
        Win32 Version: 17.2.4.0
        CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/DevExpress.Dialogs.v17.2.Core/v4.0_17.2.4.0__b88d1754d700e49a/DevExpress.Dialogs.v17.2.Core.dll
    ----------------------------------------
    DevExpress.XtraTreeList.v17.2
        Assembly Version: 17.2.4.0
        Win32 Version: 17.2.4.0
        CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/DevExpress.XtraTreeList.v17.2/v4.0_17.2.4.0__b88d1754d700e49a/DevExpress.XtraTreeList.v17.2.dll
    ----------------------------------------
    System.Data
        Assembly Version: 4.0.0.0
        Win32 Version: 4.7.3024.0 built by: NET472REL1
        CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_32/System.Data/v4.0_4.0.0.0__b77a5c561934e089/System.Data.dll
    ----------------------------------------
    System.ComponentModel.DataAnnotations
        Assembly Version: 4.0.0.0
        Win32 Version: 4.7.3024.0
        CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.ComponentModel.DataAnnotations/v4.0_4.0.0.0__31bf3856ad364e35/System.ComponentModel.DataAnnotations.dll
    ----------------------------------------
    System.Data.Linq
        Assembly Version: 4.0.0.0
        Win32 Version: 4.7.3024.0
        CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Data.Linq/v4.0_4.0.0.0__b77a5c561934e089/System.Data.Linq.dll
    ----------------------------------------
    JW_Method
        Assembly Version: 1.0.0.0
        Win32 Version: 1.0.0.0
        CodeBase: file:///C:/Users/Darren%20Rose/Downloads/DirectoryCopier_V2/DirectoryCopier.exe
    ----------------------------------------
    Anonymously Hosted DynamicMethods Assembly
        Assembly Version: 0.0.0.0
        Win32 Version: 4.7.3024.0 built by: NET472REL1
        CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_32/mscorlib/v4.0_4.0.0.0__b77a5c561934e089/mscorlib.dll
    ----------------------------------------
    
    ************** JIT Debugging **************
    To enable just-in-time (JIT) debugging, the .config file for this
    application or computer (machine.config) must have the
    jitDebugging value set in the system.windows.forms section.
    The application must also be compiled with debugging
    enabled.
    
    For example:
    
    <configuration>
        <system.windows.forms jitDebugging="true" />
    </configuration>
    
    When JIT debugging is enabled, any unhandled exception
    will be sent to the JIT debugger registered on the computer
    rather than be handled by this dialog box.
    
    
    


    Darren Rose

    Tuesday, December 26, 2017 7:08 PM
  • Okay I have tried it with a smaller source, and can recreate problem

    I have zipped up the source folder/files for you, try extracting these and setting as your source and see if you get same problem

    http://www.pcassistonline.co.uk/test/frank.zip


    Darren Rose

    Tuesday, December 26, 2017 7:20 PM
  • It's in one of the main assemblies:

    ...at StreamingFileCopier.Operations.Copier

    That assembly is doing the work.

    Copying a directory really just consists of creating the target directory and copying the files from the source to the target. That's what that's doing - but it's not actually copying them (if you remember why it's so fast?) because copying them also copies other things like the attributes. In mine, I go back and set those attributes.

    Bear with me a bit please - maybe that's where it is because that part is pretty deep inside.


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Tuesday, December 26, 2017 7:22 PM
  • Okay I have tried it with a smaller source, and can recreate problem

    I have zipped up the source folder/files for you, try extracting these and setting as your source and see if you get same problem

    http://www.pcassistonline.co.uk/test/frank.zip


    Darren Rose


    Good thinking -- I'll try that before I change anything.

    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Tuesday, December 26, 2017 7:25 PM
  • Okay I have tried it with a smaller source, and can recreate problem

    I have zipped up the source folder/files for you, try extracting these and setting as your source and see if you get same problem

    http://www.pcassistonline.co.uk/test/frank.zip


    Darren Rose

    No such luck - with mine, it copied them (using the program) without hesitation.

    I'll go back to guessing...


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Tuesday, December 26, 2017 7:32 PM
  • Okay I have tried it with a smaller source, and can recreate problem

    I have zipped up the source folder/files for you, try extracting these and setting as your source and see if you get same problem

    http://www.pcassistonline.co.uk/test/frank.zip


    Darren Rose

    No such luck - with mine, it copied them (using the program) without hesitation.

    I'll go back to guessing...


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    worth a try

    Can you check one thing for me please

    Right click > properties on the extracted Common Files folder and tell me if yours shows read only being ticked? if not then select it and then try copy program again


    Darren Rose

    Tuesday, December 26, 2017 7:37 PM

  • worth a try

    Can you check one thing for me please

    Right click > properties on the extracted Common Files folder and tell me if yours shows read only being ticked? if not then select it and then try copy program again


    Darren Rose

    I've got the revision done, just not compiled yet.

    The source directory itself (that you named "frank") show to be read-only. Is that what you mean?


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Tuesday, December 26, 2017 7:46 PM
  • Darren,

    Would you try this version:

    {Link Removed}

    Try it both ways please. There's a checkbox that's new - you'll see it when you use it.


    "A problem well stated is a problem half solved.” - Charles F. Kettering


    Tuesday, December 26, 2017 8:00 PM

  • worth a try

    Can you check one thing for me please

    Right click > properties on the extracted Common Files folder and tell me if yours shows read only being ticked? if not then select it and then try copy program again


    Darren Rose

    I've got the revision done, just not compiled yet.

    The source directory itself (that you named "frank") show to be read-only. Is that what you mean?


    "A problem well stated is a problem half solved.” - Charles F. Kettering


    yes that's it - just curious as I know in past we had different test results when files/folders set as read-only

    Darren Rose

    Tuesday, December 26, 2017 8:02 PM

  • yes that's it - just curious as I know in past we had different test results when files/folders set as read-only

    Darren Rose

    Ok, I did that and had no problem at all - they all copied over without a fuss.

    If nothing else, it's interesting. ;-)


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Tuesday, December 26, 2017 8:09 PM
  • With checkbox checked:-

    Now trying it again with checkbox unchecked


    Darren Rose

    Tuesday, December 26, 2017 8:24 PM
  • with checkbox unchecked:-

    destination file count - 38,981 - so only difference between two methods is 2 files


    Darren Rose

    Tuesday, December 26, 2017 8:40 PM
  • with checkbox unchecked:-

    destination file count - 38,981 - so only difference between two methods is 2 files


    Darren Rose

    What about errors? I didn't change anything in that regard.

    How usable is what got copied?


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Tuesday, December 26, 2017 8:42 PM
  • that same error comes up regularly using both methods

    Not very useful, out of the two main folders I definitely need, only one copied

    One way to perhaps solve this would be if you had exact same source as I do, but that would depend if you had access or would download a Windows 10 ISO file, then I could provide you simple instructions to recreate exactly the same source folder as I am using? just an idea?


    Darren Rose

    Tuesday, December 26, 2017 8:50 PM
  • that same error comes up regularly using both methods

    Not very useful, out of the two main folders I definitely need, only one copied

    One way to perhaps solve this would be if you had exact same source as I do, but that would depend if you had access or would download a Windows 10 ISO file, then I could provide you simple instructions to recreate exactly the same source folder as I am using? just an idea?


    Darren Rose

    It's no secret that I'm easily a dozen (or more) years behind times. I know that - I'm not blind to the scathing that others here think I am. Just yesterday I talked to my daughter and son-in-law and rather than getting them to build a new computer with a new O/S (they built this one in 2012), they suggest that I get a cheap one with Win10 on it and that I then get used to the new operating system. Do you agree with that?

    *****

    Currently, you're dealing with something that I can't deal with. Someone else here would obviously be in a much better situation to work with it.


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Tuesday, December 26, 2017 8:55 PM

  • It's no secret that I'm easily a dozen (or more) years behind times. I know that - I'm not blind to the scathing that others here think I am. Just yesterday I talked to my daughter and son-in-law and rather than getting them to build a new computer with a new O/S (they built this one in 2012), they suggest that I get a cheap one with Win10 on it and that I then get used to the new operating system. Do you agree with that?

    Frank,

    Maybe it is the time of the year to respond this to you.  I find the questions of Darren not productive. That is my way of thinking about that, so never mind. I don't know how professional you were involved in this business. Some active in this forum were. We know what was yesterday the ultimate solution told by the marketing guys is today a stupid idea to follow. Therefore if you are on the age as we are. Simply take your own knowledge as guide. We are to old to take the perfect decisions, but we should know what are just marketing guys decisions. (Sorry for persons as  Steve Ballmer who most of the time perfectly knew what they did.) 


    Success Cor


    Tuesday, December 26, 2017 9:08 PM


  • Frank,

    Maybe it is the time of the year to respond this to you.  I find the questions of Darren not productive. That is my way of thinking about that, so never mind. I don't know how professional you were involved in this business. Some active in this forum were. We know what was yesterday the ultimate solution told by the marketing guys is today a stupid idea to follow. Therefore if you are on the age as we are. Simply take your own knowledge as guide. We are to old to take the perfect decisions, but we should know what are just marketing guys decisions. (Sorry for persons as  Steve Ballmer who most of the time perfectly knew what they did.) 


    Success Cor


    Cor,

    I'm not involved in this industry at all, but I do have to live in it.

    Still though, just because something is 'new' doesn't make it better. With what we're talking about here, some things were/are different - that's all.

    But other things - no, the technology simply didn't exist then. I have to move on and learn the new -- or at least try. ;-)


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Tuesday, December 26, 2017 9:13 PM
  • It's no secret that I'm easily a dozen (or more) years behind times. I know that - I'm not blind to the scathing that others here think I am. Just yesterday I talked to my daughter and son-in-law and rather than getting them to build a new computer with a new O/S (they built this one in 2012), they suggest that I get a cheap one with Win10 on it and that I then get used to the new operating system. Do you agree with that?

    *****

    Currently, you're dealing with something that I can't deal with. Someone else here would obviously be in a much better situation to work with it.


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    That's fair enough, if you have been happy with what you use then not a problem, not always a reason to move forward unless you really want to - if what you have does what you need then it is fine.  Newer is not always better, but sometimes it can be fun to learn and move forward.

    What I would say though is from a development point of view moving forward to Windows 10 does give you a lot more fun things to play around with, the ability to use newer versions of .NET and DevExpress goodies!! - and as Windows 10 is here to stay (so they say!) I would certainly suggest giving it a go

    I always used to be a fan of building my own PC's, but the last time I got a new one I found I could buy off the shelf much cheaper than I could source the same components, so decided to for the first time ever by a pre-built machine, which so far has worked well for me

    If you do decide to got for a "cheap" machine to try Windows 10 on, all I would say is don't go too cheap so that it is quite low spec, as Windows 10 really won't run that well on it, and you may be put off before you get a chance to explore more

    As my business I spend a lot of time recommending, supplying and helping customers source new computers and find those that buy too cheap really do soon regret it and find Windows 10 a pain to use, whereas those who make sure they get something powerful enough to run okay soon get used the "newness" of Windows 10 and start to embrace it

    See my website which my customers use, where I have lots of advice and recommendations on this area, some which may be of use to you perhaps - always happy to help on this subject either here on forum or via email (link on website) - as good to be able to help you as much as you help me

    http://www.pcassistonline.co.uk/HelpandAdvice/buyers_guide.html


    Darren Rose

    Tuesday, December 26, 2017 9:16 PM
  • Darren,

    Thanks for that - I'll have a look at some point and I understand what you're saying.

    I'm jumping from XP all the way to 10 though and that's quite a leap. I tried 7 and it wasn't horrible until I got to the core O/S operations and that did nothing but make me want to throw it through the window.

    **********
    -- Anyway --
    **********

    This is your question and it's so far unresolved. I'll help if I can but I don't know that I can, so I'll be quiet and watch. ;-)


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Tuesday, December 26, 2017 9:23 PM
  • Darren,

    Thanks for that - I'll have a look at some point and I understand what you're saying.

    I'm jumping from XP all the way to 10 though and that's quite a leap. I tried 7 and it wasn't horrible until I got to the core O/S operations and that did nothing but make me want to throw it through the window.

    **********
    -- Anyway --
    **********

    This is your question and it's so far unresolved. I'll help if I can but I don't know that I can, so I'll be quiet and watch. ;-)


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    My pleasure

    **

    Thanks

    I think anyway as I have worked through this, that I only need a small subset (500mb) of the files anyway, so really no point in me copying the whole lot (11.9Gb) - so permissions shouldn't be such an issue hopefully

    Therefore all I need to do is copy the required files with some sort of indication of progress - nothing to special, just provide source, destination and show progress bar of file copy progress

    Will keep working on it, and confirm first that is all I need


    Darren Rose

    Tuesday, December 26, 2017 9:33 PM

  • I think anyway as I have worked through this, that I only need a small subset (500mb) of the files anyway, so really no point in me copying the whole lot (11.9Gb) - so permissions shouldn't be such an issue hopefully

    Therefore all I need to do is copy the required files with some sort of indication of progress - nothing to special, just provide source, destination and show progress bar of file copy progress

    Will keep working on it, and confirm first that is all I need


    Darren Rose

    If it proves to be beneficial then I'll make sure that you have it, but not via this forum. I'm not giving it away to the world.

    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Tuesday, December 26, 2017 9:39 PM
  • If it proves to be beneficial then I'll make sure that you have it, but not via this forum. I'm not giving it away to the world.


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Thanks Frank

    All contact details on my website if ever you need to contact me for anything outside the forum, always happy to help you in return for all the great help you give me :)


    Darren Rose

    Tuesday, December 26, 2017 10:16 PM
  • Hi Frank

    I hope you are well and that 2018 has started positively for you

    Coming back to this topic (and the other one about explorer clone), I have managed to create what I need in relation to a file explorer to use in Windows PE and it works well

    What I still need to do (and I am hoping you might have some pointers or be able to help with!) is a file/folder copy/move with progress facility

    In Windows PE I have copy/paste working to move/copy files but we don't get progress bar, which obviously is an issue when copying lots of files as no idea how it is doing etc

    So i have got rid of the standard right click context menu for copy/paste and want to add in my own facility for copying files with my own simple GUI with progress bar just like you get normally in Windows

    So would need to be able to select source file/folder, click "copy" (or "cut") and it enumerates selected items and then adds these to a "list", then click in destination and select "paste" and it then shows a dialog showing current file/folder and a simple progress bar and then proceeds with copying (or moving) the selected files

    Thoughts? comments?

    Thank you :) 


    Darren Rose

    Friday, January 19, 2018 11:55 AM
  • Darren,

    I'm not very active here now; certainly not like I used to be.

    I have lots of thoughts, but if you're satisfied with the conventional things (like the progress shown when copying a file) then go down that road.

    I prefer to "roll my own" and that's what I've been doing for some time now - but it does take a change in thinking. ;-)


    "A problem well stated is a problem half solved.” - Charles F. Kettering


    • Edited by Frank L. Smith Friday, January 19, 2018 2:35 PM ...formatting
    Friday, January 19, 2018 2:33 PM
  • Hi Frank

    Shame to hear you are not around so much - had fun in past working on projects with you

    I can't use the standard progress dialog shown when copying a file as it doesn't work in Windows PE - hence needing to "roll my own", and I thought the one we mentioned in previous posts above you had may perhaps work for it?


    Darren Rose

    Friday, January 19, 2018 5:33 PM
  • Hi Frank

    Shame to hear you are not around so much - had fun in past working on projects with you

    I can't use the standard progress dialog shown when copying a file as it doesn't work in Windows PE - hence needing to "roll my own", and I thought the one we mentioned in previous posts above you had may perhaps work for it?


    Darren Rose

    It's the current zeitgeist - I don't like how this forum has turned out since I joined nearly a decade ago.

    I don't know Windows PE nor the framework version that matches with it. If the directory copier worked though that's most of it.

    Confirm that it worked please?


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Friday, January 19, 2018 5:43 PM
  • Oh I see - have you found another forum which is better to frequent?

    PE not really relevant, as it runs most .NET stuff I have thrown at it so far

    Sorry which directory copier do you mean? let me know and I can test it


    Darren Rose

    Friday, January 19, 2018 5:55 PM
  • Oh I see - have you found another forum which is better to frequent?

    PE not really relevant, as it runs most .NET stuff I have thrown at it so far

    Sorry which directory copier do you mean? let me know and I can test it


    Darren Rose

    No, no other forum ... I just don't post here much any longer.

    If you look through this, I made a Dev directory copier. Does that work on PE?


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Friday, January 19, 2018 5:57 PM
  • No, no other forum ... I just don't post here much any longer.

    If you look through this, I made a Dev directory copier. Does that work on PE?

    Well I can say I would certainly miss you around here, you have been very kind and helpful to me over the years, and without your input and help I wouldn't know what I know now, so I definitely appreciate what you do.

    All links above seem to say {Link Removed}


    Darren Rose

    Friday, January 19, 2018 6:05 PM
  • All links above seem to say {Link Removed}

    Darren Rose

    Ok - bear with me a bit please.

    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Friday, January 19, 2018 6:08 PM
  • All links above seem to say {Link Removed}

    Darren Rose

    Ok,

    Version 3 Here

    It was built on December 26 but I don't remember the changes made.


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Friday, January 19, 2018 6:17 PM
  • Can you do me a favour and compile it as 64-bit, as that is the ONLY prerequisite for running it in PE, so under Properties of the project, on the compile tab, set Target CPU to 64-bit please

    Thanks Frank


    Darren Rose


    • Edited by wingers Friday, January 19, 2018 6:32 PM typo
    Friday, January 19, 2018 6:32 PM
  • Can you do me a favour and compile it as 64-bit, as that is the ONLY prerequisite for running it in PE, so under Properties of the project, on the compile tab, set Target CPU to 64-bit please

    Thanks Frank


    Darren Rose


    It uses an assembly (32-bit) so I'll first try to ignore that part and move directly to the application.

    I'll back in a bit...


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Friday, January 19, 2018 6:36 PM
  • Can you do me a favour and compile it as 64-bit, as that is the ONLY prerequisite for running it in PE, so under Properties of the project, on the compile tab, set Target CPU to 64-bit please

    Thanks Frank


    Darren Rose


    Let me know how this version fares please?

    https://fls.exavault.com/share/view/4w3j-85852xve


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Friday, January 19, 2018 6:50 PM
  • it runs, but when I click Select Folder it crashes - very hard to diagnose why when all in one EXE like that - if you are using latest DevExpress then just let me have the main executable and I will use my own Dev DLL's if you tell me which ones it is using? or if not can you somehow provide project or a version where not all in one EXE

    Sorry Frank - I know I am a pain


    Darren Rose

    Friday, January 19, 2018 7:05 PM
  • it runs, but when I click Select Folder it crashes - very hard to diagnose why when all in one EXE like that - if you are using latest DevExpress then just let me have the main executable and I will use my own Dev DLL's if you tell me which ones it is using? or if not can you somehow provide project or a version where not all in one EXE

    Sorry Frank - I know I am a pain


    Darren Rose

    So you never did run it then?

    I remember you said it ran but failed to copy two files. Do you remember it showing progress? That's what I was going to end up asking about anyway.


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Friday, January 19, 2018 7:11 PM
  • So you never did run it then?

    I remember you said it ran but failed to copy two files. Do you remember it showing progress? That's what I was going to end up asking about anyway.


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Over Christmas - yes I did run it, but that was in Windows 10 NOT Windows PE, so yes it worked fine, and showed progress

    Now we are trying it in Windows PE hence asking for it in 64-bit - that is where it launches fine, but clicking select folder causes an exception

    Yes I liked how it showed progress, if I can get similar in PE then fantastic, just can't test it as per previous reply


    Darren Rose

    Friday, January 19, 2018 7:21 PM

  • Over Christmas - yes I did run it, but that was in Windows 10 NOT Windows PE, so yes it worked fine, and showed progress

    Now we are trying it in Windows PE hence asking for it in 64-bit - that is where it launches fine, but clicking select folder causes an exception

    Yes I liked how it showed progress, if I can get similar in PE then fantastic, just can't test it as per previous reply


    Darren Rose

    Oh ok - I understand now.

    My point is that if you like the status quo stuff then go that route, but if you like something more custom then you have to start from scratch -- sort of.

    The dotNET framework gives you what you need. You don't need to literally go into the O/S - just skip the methods that are meant to do what most people do; do your own instead.

    What do you recall of the first (and later, the second) file copying routine? Those two will explain a lot about where you are.

    Copying a file and moving a file are the same thing (nearly) if you let be. That's what I meant about changing how you think. Here's an example: Look at System.IO.File and using only that class, how would you rename a file?


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Friday, January 19, 2018 7:28 PM
  • Quite happy to use system.io.file.move or system.io.file.copy - and have also used my.computer.filesystem.movefile and my.computer.filesystem.copyfile and the directory equivalents

    But none of these give me the progress bar and indication of what files/folders are copying etc - and this is what I need

    All of those above methods fine,  but have had issues in past using those, which worked better using a more custom method like you created in the backup tool last year etc

    Remind me of the first and second copying routine as forgot the differences then I can answer

    Using System.IO you could rename a file by supplying different name for source and destination


    Darren Rose

    Friday, January 19, 2018 7:39 PM

  • Using System.IO you could rename a file by supplying different name for source and destination


    Darren Rose

    And that's all you have:

    Imports System.IO
    Imports System.IO.Path
    
    Public Class Form1
        Private Sub _
            Form1_Load(sender As System.Object, _
                       e As System.EventArgs) _
                       Handles MyBase.Load
    
            Dim desktop As String = _
                Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
    
            Dim sourceDir As String = Combine(desktop, "ImagesCopy")
    
            Dim subDir As String = Combine(sourceDir, "106_1120")
    
            Dim sourceFilePath As String = Combine(subDir, "IMGP0964.JPG")
    
            If File.Exists(sourceFilePath) Then
                RenameFile(sourceFilePath, "NewName.jpg")
            End If
    
            Stop
    
        End Sub
    
        Private Sub _
            RenameFile(ByVal originalFilePath As String, _
                       ByVal newFileName As String)
    
            ' All of the following assumes that
            ' permissions aren't an issue here.
            ' 
            ' Also, this should be overloaded
            ' to allow some optional things
            ' like keeping the original file's
            ' extension.
    
            Try
                If String.IsNullOrWhiteSpace(originalFilePath) Then
                    Throw New ArgumentException("The original file path cannot be null or empty.")
    
                ElseIf String.IsNullOrWhiteSpace(newFileName) Then
                    Throw New ArgumentException("The new file name cannot be null or empty.")
    
                Else
                    Dim fi As New FileInfo(originalFilePath)
    
                    If fi.Exists Then
                        ' A few other checks should be done
                        ' here but for simplicity, I'll
                        ' skip them.
                        '
                        ' By creating a new instance of
                        ' FileInfo using the new file's
                        ' name, it automatically tests for
                        ' several errant conditions:
                        ' 
                        ' It checks to be sure there are no
                        ' illegal file/path characters and
                        ' it checks that the path's length
                        ' is within the O/S limits.
    
                        Dim newPath As New FileInfo(Combine(fi.DirectoryName, newFileName))
    
                        If newPath.Exists Then
                            newPath.Delete()
                        End If
    
                        fi.MoveTo(newPath.FullName)
                    Else
                        Throw New FileNotFoundException("The original file path could not be located.", fi.FullName)
                    End If
                End If
    
            Catch ex As Exception
                MessageBox.Show(String.Format("An error occurred:{0}{0}{1}", _
                                              vbCrLf, ex.Message), _
                                              "Exception Thrown", _
                                              MessageBoxButtons.OK, _
                                              MessageBoxIcon.Warning)
    
            End Try
    
        End Sub
    End Class

    ...but I never went out of the framework and I never needed to. I'll explain the two methods (an overview following this).


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Friday, January 19, 2018 7:44 PM

  • But none of these give me the progress bar and indication of what files/folders are copying etc - and this is what I need

    All of those above methods fine,  but have had issues in past using those, which worked better using a more custom method like you created in the backup tool last year etc

    Remind me of the first and second copying routine as forgot the differences then I can answer

    Using System.IO you could rename a file by supplying different name for source and destination


    Darren Rose

    For the first one, John Wein speculated that using a WebClient would do everything needed and that's what I used. It's sort of slow but it works and reports progress.

    That's not what I did with the second one though; not even close. Do you not remember at all?


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Friday, January 19, 2018 7:48 PM
  • ...but I never went out of the framework and I never needed to. I'll explain the two methods (an overview following this).


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Yes that make sense and have used similar before for basic copying/moving and renaming of files

    Darren Rose

    Friday, January 19, 2018 7:53 PM
  • For the first one, John Wein speculated that using a WebClient would do everything needed and that's what I used. It's sort of slow but it works and reports progress.

    That's not what I did with the second one though; not even close. Do you not remember at all?


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    I definitely remember the WebClient used on the first one and that it worked okay

    The second one I can't remember method used, but seem to remember it was quicker?


    Darren Rose

    Friday, January 19, 2018 7:53 PM

  • I definitely remember the WebClient used on the first one and that it worked okay

    The second one I can't remember method used, but seem to remember it was quicker?


    Darren Rose

    I wish I were proficient with Illustrater (I don't even have it) and I'm not going to open AutoCAD and PhotoShop for this. This is how it works though:

    There are two FileStream objects. In between, there's a reservoir (a byte buffer) The first FileStream reads the original file and byte-by-byte, it fills up that reservoir. When it's full, the second FileStream now reads the bytes from the reservoir and it doesn't "copy" the file, it creates a NEW file at that new path. It creates the directory if it doesn't exist.

    It's not really copying the file; it's using the original file as a "template" to then create a new file from. It may as well be copying it but for a little:

    The metadata isn't copied over.

    It's a new file; the new file gets all the meta that a new file does. So that now means that it's on me to get and set the new file's attributes and permissions. That slows things down again but true copying does that automatically.

    The size of that byte buffer (the "reservoir") was part and parcel of many discussions.


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Friday, January 19, 2018 8:02 PM
  • I remember it now you have explained it again - sorry was being vague for a moment! - but yes definitely coming back to me now

    Darren Rose

    Friday, January 19, 2018 8:07 PM
  • I remember it now you have explained it again - sorry was being vague for a moment! - but yes definitely coming back to me now

    Darren Rose

    Ok good - to sum up, you have everything needed.

    To get a WindowsPE assembly - something you can test and I cannot - and to report progress and all that, you need to do your own. It's there, in one way or another.

    Think it through. :)


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Friday, January 19, 2018 8:11 PM
  • Okay, not really sure where to start but will look back at previous project tomorrow and have a go- was hoping not to do that as was quite complex if I remember correctly and this only needs to be much simpler, just supply a list of files or folders, choose if copying or moving and then do it with progress bar

    Darren Rose

    Friday, January 19, 2018 8:14 PM
  • Okay, not really sure where to start but will look back at previous project tomorrow and have a go- was hoping not to do that as was quite complex if I remember correctly and this only needs to be much simpler, just supply a list of files or folders, choose if copying or moving and then do it with progress bar

    Darren Rose

    Eventually it will be that - or close.

    One of the basic concepts of OOP is abstraction. This is that - the details will emerge in time.

    It's all there. Try it. :)


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Friday, January 19, 2018 8:18 PM
  • Eventually it will be that - or close.

    One of the basic concepts of OOP is abstraction. This is that - the details will emerge in time.

    It's all there. Try it. :)


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Okay I will have a go

    Keep in touch Frank


    Darren Rose

    Saturday, January 20, 2018 12:32 AM
  • Keep in touch Frank

    Darren Rose

    I'm never far. :)

    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Saturday, January 20, 2018 4:47 PM
  • Hi Frank

    If you ever have any spare time I would appreciate your skills

    I have created my file explorer (using some wonderful components from https://www.jam-software.com/shellbrowser_net/)

    I have implemented context menu / buttons for cut/copy and paste which gives me the following information:-

    1) A list in string format of all selected source files and folders

    2) the selected destination location

    3) whether copy or cut was chose so I know if to copy OR move

    As I can't rely in PE on the standard file copy progress dialog I need my own

    So now I have the files/folders I need to copy/move, destination and whether to move or copy, what I need is to be able to pass these three bits of information to a class which pops up a little dialog box showing progress e.g. current file/folder, processes the copy/move and gives rough estimation of time / progress, which I assume I can just base on number of files rather than working out a time

    Can you possibly help me?


    Darren Rose


    • Edited by wingers Saturday, February 17, 2018 5:33 PM
    Saturday, February 17, 2018 5:33 PM