{"id":6441,"date":"2021-11-19T08:07:24","date_gmt":"2021-11-19T08:07:24","guid":{"rendered":"https:\/\/lgildv5i97.onrocket.site\/answers\/?post_type=question&#038;p=6441"},"modified":"2021-11-19T08:07:49","modified_gmt":"2021-11-19T08:07:49","slug":"need-help-with-timing-and-waiting-until-process-ends","status":"publish","type":"question","link":"https:\/\/computing.net\/answers\/programming\/need-help-with-timing-and-waiting-until-process-ends\/28185.html","title":{"rendered":"Need Help With Timing And Waiting Until Process Ends"},"content":{"rendered":"<p>I am currently trying to make a program in Visual Basic ( not .net or scipting or anything else, just the regular one) in which the following happens:<\/p>\n<p>1: A folder is created<br \/>\n2: Files are copied to that folder<br \/>\n3: Files in that folder undergo a change<br \/>\n4: The files in that folder are then copied to another folder<br \/>\n5: The folder is then deleted<\/p>\n<p>I am basically trying to make a file copied to a new folder where a batch changes its name and then the files are copied to a different folder. Then the folder that was created is destroyed. The problem is that once the system starts to copy the folders, it doesn&#8217;t wait until that process is done, it just goes on to the next process of deleting or renaming. I have tried looking at other forums and doing research but I can&#8217;t seem to do it correctly. Here is my code:<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>\nPrivate Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click<br \/>\nMy.Computer.FileSystem.CreateDirectory(&#8220;C:\\Documents and Settings\\Allan\\Desktop\\Monograms\\-23&#8221;)<br \/>\nMy.Computer.FileSystem.CreateDirectory(&#8220;C:\\Documents and Settings\\Allan\\Desktop\\Monograms\\-3&#8221;)<br \/>\nMe.Hide()<br \/>\nIf CheckBox1.CheckState = 0 Then<br \/>\nMy.Computer.FileSystem.CopyDirectory(&#8220;C:\\Documents and Settings\\Allan\\Desktop\\Monograms\\SAVE&#8221;, &#8220;C:\\Documents and Settings\\Allan\\Desktop\\Monograms\\123&#8221;, FileIO.UIOption.AllDialogs, FileIO.UICancelOption.DoNothing)<br \/>\nMy.Computer.FileSystem.CopyDirectory(&#8220;C:\\Documents and Settings\\Allan\\Desktop\\Monograms\\SAVE&#8221;, &#8220;C:\\Documents and Settings\\Allan\\Desktop\\Monograms\\-23&#8221;, FileIO.UIOption.AllDialogs, FileIO.UICancelOption.DoNothing)<br \/>\nMy.Computer.FileSystem.CopyDirectory(&#8220;C:\\Documents and Settings\\Allan\\Desktop\\Monograms\\SAVE&#8221;, &#8220;C:\\Documents and Settings\\Allan\\Desktop\\Monograms\\-3&#8221;, FileIO.UIOption.AllDialogs, FileIO.UICancelOption.DoNothing)<br \/>\nEnd If<br \/>\nIf CheckBox1.CheckState = 1 Then<br \/>\nMy.Computer.FileSystem.CopyDirectory(&#8220;C:\\Documents and Settings\\Allan\\Desktop\\Monograms\\Save&#8221;, &#8220;C:\\Documents and Settings\\Allan\\Desktop\\Monograms\\123&#8221;, True)<br \/>\nMy.Computer.FileSystem.CopyDirectory(&#8220;C:\\Documents and Settings\\Allan\\Desktop\\Monograms\\Save&#8221;, &#8220;C:\\Documents and Settings\\Allan\\Desktop\\Monograms\\-23&#8221;, True)<br \/>\nMy.Computer.FileSystem.CopyDirectory(&#8220;C:\\Documents and Settings\\Allan\\Desktop\\Monograms\\Save&#8221;, &#8220;C:\\Documents and Settings\\Allan\\Desktop\\Monograms\\-3&#8221;, True)<br \/>\nEnd If<br \/>\nSystem.Diagnostics.Process.Start(&#8220;C:\\Documents and Settings\\Allan\\Desktop\\Monograms\\Properties\\Renamer1.bat&#8221;)<br \/>\nSystem.Diagnostics.Process.Start(&#8220;C:\\Documents and Settings\\Allan\\Desktop\\Monograms\\Properties\\Renamer2.bat&#8221;)<br \/>\nSystem.Diagnostics.Process.Start(&#8220;C:\\Documents and Settings\\Allan\\Desktop\\Monograms\\Properties\\Renamer3.bat&#8221;)<br \/>\nMy.Computer.FileSystem.CopyDirectory(&#8220;C:\\Documents and Settings\\Allan\\Desktop\\Monograms\\-23&#8221;, &#8220;C:\\Documents and Settings\\Allan\\Desktop\\Monograms\\23&#8221;)<br \/>\nMy.Computer.FileSystem.CopyDirectory(&#8220;C:\\Documents and Settings\\Allan\\Desktop\\Monograms\\-3&#8221;, &#8220;C:\\Documents and Settings\\Allan\\Desktop\\Monograms\\3&#8221;)<br \/>\nMy.Computer.FileSystem.DeleteDirectory(&#8220;C:\\Documents and Settings\\Allan\\Desktop\\Monograms\\-23&#8221;, FileIO.DeleteDirectoryOption.DeleteAllContents)<br \/>\nMy.Computer.FileSystem.DeleteDirectory(&#8220;C:\\Documents and Settings\\Allan\\Desktop\\Monograms\\-3&#8221;, FileIO.DeleteDirectoryOption.DeleteAllContents)<br \/>\nEnd Sub<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/p>\n<p>So if you study this code carefully, you can see that I want this to go one at a time. The problem with timers is that they automatically have a set time, but they don&#8217;t know how long it will take to copy the files. Sometimes the file size will be huge, sometimes the file size will be small. I want the code to do this one at a time and wait until the other process has finished! Please try to adjust and customize the code to my scenerio since when people put a<\/p>\n<p>*.* or other symbols I don&#8217;t really know,<\/p>\n<p>I don&#8217;t understand how to apply it to my case&#8230;<\/p>\n<p>So just for my case please try to adjust the code so I don&#8217;t need to worry about certain places I need to fill in.<br \/>\nSorry about the length of my problem.<br \/>\nPlease write back ASAP since I need to get this ground covered already.<br \/>\nMuch appreciated,<br \/>\nAllan.<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"inline_featured_image":false,"iawp_total_views":20},"question-category":[55],"question_tags":[],"class_list":["post-6441","question","type-question","status-publish","hentry","question-category-programming"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question\/6441","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question"}],"about":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/types\/question"}],"author":[{"embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/comments?post=6441"}],"wp:attachment":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/media?parent=6441"}],"wp:term":[{"taxonomy":"question-category","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question-category?post=6441"},{"taxonomy":"question_tags","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question_tags?post=6441"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}