473,761 Members | 4,511 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to replicate file/s "x" times in a directory all with dynamic values at runtime?

43 New Member
Hello,

I am trying to create a program that would replicate different selected files "x" times into a specified directory and save them with filename indexes. Then after create a log list of the successfully copied files via LogListBtn click ( maybe saving the text file in the C: root)

ex.
a. Help.txt ( copy 3x ), Report.xls ( copy 2x )

When they are saved in a specified directory they should look like:

Help(1).txt
Help(2).txt
Help(3).txt
Report(1).xls
Report(2).xls

By the way this is my code in adding the selected files by drag dropping them in a FRAME, then creating 2 textboxes in 1 row where:

Text1 ( as textbox ) - where full path and filename is displayed
CopyTimes ( as textbox ) - number entry for x times a file is to be copied

Expand|Select|Wrap|Line Numbers
  1. Private Sub DropArea_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
  2. Dim i As Integer
  3. Dim dCount As Integer
  4.  
  5.       On Error GoTo No_File_info
  6.       i = Text1.count - 1
  7.  
  8.       For dCount = 1 To Data.Files.count
  9.  
  10.          Load Text1(i + dCount)
  11.          With Text1(i + dCount)
  12.             .Top = Text1(i + dCount - 1).Top + Text1(0).Height
  13.             .Text = (Data.Files.Item(dCount))
  14.             .Visible = True
  15.  
  16.          End With
  17.  
  18.          Load CopyTimes(i + dCount)
  19.          With CopyTimes(i + dCount)
  20.             .Top = CopyTimes(i + dCount - 1).Top + CopyTimes(0).Height
  21.             '.Text = i + dCount
  22.             .Visible = True
  23.          End With
  24.  
  25.       Next
  26.       FrameSlide.Height = Text1.count * Text1(0).Height
  27.       If FrameSlide.Height > FrameFix.Height Then
  28.          With VScrollFiles
  29.             .Max = (FrameSlide.Height - FrameFix.Height) / 10
  30.             .SmallChange = 200
  31.             .LargeChange = FrameFix.Height / 10
  32.             .Visible = True
  33.          End With
  34.       Else
  35.          VScrollFiles.Visible = False
  36.       End If
  37. Exit Sub
  38. No_File_info:
  39.    MsgBox "No File name from Explorer"
  40. End Sub
  41.  
I can't seem to find a code on how to replicate these files to my destination directory which is at SaveTo ( as textbox ).


This is the full code of the program:
Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2. Dim fselectIDX As Integer
  3.  
  4. Private Sub CopyTimes_KeyPress(Index As Integer, KeyAscii As Integer)
  5. If Not (KeyAscii = vbKeyBack) Then
  6.     If Not Chr(KeyAscii) Like "#" Then
  7.     KeyAscii = 0
  8.     MsgBox ("Number entry only.")
  9.     End If
  10. End If
  11. End Sub
  12.  
  13. Private Sub Form_Load()
  14.     DropArea.OLEDropMode = 1      '§ manual
  15.     Text1(0).Top = -Text1(0).Height + 180
  16.     CopyTimes(0).Top = -CopyTimes(0).Height + 180
  17.  
  18.     With VScrollFiles
  19.       .Visible = False
  20.       .Min = -30
  21.    End With
  22.  
  23. End Sub
  24.  
  25.  
  26. Private Sub Dir1_Click()
  27. SaveTo.Text = Dir1.Path
  28. End Sub
  29.  
  30. Private Sub Drive1_Change()
  31. Dir1.Path = Drive1.Drive
  32. End Sub
  33.  
  34. Private Sub OpenWEBtn_Click()
  35.     Dim Det As Long
  36.     Det = Shell("explorer.exe /e, C:\", vbNormalFocus)
  37. End Sub
  38.  
  39. Private Sub DropArea_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
  40. Dim i As Integer
  41. Dim dCount As Integer
  42.  
  43.       On Error GoTo No_File_info
  44.       i = Text1.count - 1
  45.  
  46.       For dCount = 1 To Data.Files.count
  47.  
  48.          Load Text1(i + dCount)
  49.          With Text1(i + dCount)
  50.             .Top = Text1(i + dCount - 1).Top + Text1(0).Height
  51.             .Text = (Data.Files.Item(dCount))
  52.             .Visible = True
  53.  
  54.          End With
  55.  
  56.          Load CopyTimes(i + dCount)
  57.          With CopyTimes(i + dCount)
  58.             .Top = CopyTimes(i + dCount - 1).Top + CopyTimes(0).Height
  59.             '.Text = i + dCount
  60.             .Visible = True
  61.          End With
  62.  
  63.  
  64.       Next
  65.       FrameSlide.Height = Text1.count * Text1(0).Height
  66.       If FrameSlide.Height > FrameFix.Height Then
  67.          With VScrollFiles
  68.             .Max = (FrameSlide.Height - FrameFix.Height) / 10
  69.             .SmallChange = 200
  70.             .LargeChange = FrameFix.Height / 10
  71.             .Visible = True
  72.          End With
  73.       Else
  74.          VScrollFiles.Visible = False
  75.       End If
  76. Exit Sub
  77. No_File_info:
  78.    MsgBox "No File name from Explorer"
  79. End Sub
  80.  
  81.  
  82. Private Sub Text1_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
  83.    fselectIDX = Index
  84.    If Button = vbKeyLButton Then PopupMenu PUMenu_Files
  85. End Sub
  86. '§ =============================================
  87. '§ MENUS
  88. '§ =============================================
  89.  
  90. Private Sub PUMenu_DeleteFile_Click()
  91. Dim BOXidx As Integer
  92.    If fselectIDX <> Text1.count Then '§ if not last box
  93.       For BOXidx = fselectIDX To Text1.count - 2
  94.          Text1(BOXidx).Text = Text1(BOXidx + 1).Text
  95.          CopyTimes(BOXidx).Text = CopyTimes(BOXidx + 1).Text
  96.       Next
  97.       Unload Text1(Text1.count - 1)
  98.       Unload CopyTimes(CopyTimes.count - 1)
  99.    Else '§ if last box
  100.       Unload Text1(fselectIDX)
  101.       Unload CopyTimes(fselectIDX)
  102.    End If
  103.    Call Calc_FrameSlide_Height
  104. End Sub
  105.  
  106. Private Sub VScrollFiles_Change()
  107. FrameSlide.Top = -VScrollFiles.Value * 10
  108. End Sub
  109.  
  110. '§ =============================================
  111. '§ FUNCTIONS
  112. '§ =============================================
  113.  
  114. Private Function Calc_FrameSlide_Height()
  115.    FrameSlide.Height = Text1.count * Text1(0).Height
  116.    If FrameSlide.Height > FrameFix.Height Then
  117.       With VScrollFiles
  118.          .Max = (FrameSlide.Height - FrameFix.Height) / 10
  119.          .SmallChange = 200
  120.          .LargeChange = FrameFix.Height / 10
  121.          .Visible = True
  122.       End With
  123.    Else
  124.       VScrollFiles.Visible = False
  125.    End If
  126. End Function
  127.  
Tool UI:



Buttons not working yet are:
a. Replicate Button
- should be able to replicate selected file/s into destination directory "x" times
b. Log List Button
- should be able to create a text file saved at C: root drive with name LogList.txt with format:

1. file(1).txt
2. file(2).txt
3. file(3).txt
4. file(1).xls
5. file(2).xls
.......



Please help.
Thanks!
Jan 4 '11 #1
1 1338
blurryanthem
43 New Member
correction for the Tool UI ( I removed the checkboxes already).

I hope somebody could help me.

Thank You.
Jan 4 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

43
5125
by: steve | last post by:
I am quite frustrated with php’s include, as I have spent a ton of time on it already... anyone can tell me why it was designed like this (or something I don’t get)? The path in include is relative NOT to the immediate script that is including it, but is relative to the top-level calling script. In practice, this means that you have to constantly worry and adjust paths in includes, based on the startup scripts that call these...
0
10211
by: Jan | last post by:
I store sql-commands in a database table. In the first step I get the sql command out of the database table with embedded sql. In the second step I try to execute the command, which i got from the database table, using dynamic sql. Executing 'EXEC SQL DESCRIBE SELECT LIST FOR S INTO select_dp;' the error code -2149 is returned That means "Specified partition does not exist". Does anybody know if it is a database problem or a problem of
11
2169
by: brian.newman | last post by:
I'm trying to use a layer inside a form to hide/reveal a part of the form, but my code doesn't seem to be working and I need some help debugging it. I'm not getting an error which has made it difficult to debug the code, but I am getting the alert ("break 4 in getStyleObject"); which makes me think this is a browser compatability issue (I'm running IE 6.0). Anyway, the code follows function getStyleObject (objectId) { alert ("begin...
3
3697
by: | last post by:
I am working on a web/webservice application that has a service layer. Most service methods will perform an access-check before executing. This check uses the IPrincipal credentials available in HttpContext.Current. This works great. My issue is that I need to write unit tests for those service methods. These tests then run outside of IIS, thus there is no HttpContext.Current available - and the servicemethod will not execute. The two...
21
4980
by: nicholas | last post by:
Although in my web.config I have <customErrors mode="off" /> I still get no detailed errors. How comes ? THX This is what I get: Server Error in '/mywebfolder'Application.
5
39030
by: Savas Ates | last post by:
I have a web application It works well in my local folder.. When i upload it to my web server i got To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".
1
6508
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting" setting to be "E_ALL", notices are still not getting reported. The perms on my file are 664, with owner root and group root. The php.ini file is located at /usr/local/lib/php/php.ini. Any ideas why the setting does not seem to be having an effect? ...
23
7416
by: sandy | last post by:
I need (okay, I want) to make a dynamic array of my class 'Directory', within my class Directory (Can you already smell disaster?) Each Directory can have subdirectories so I thought to put these in an array. The application compiles but aborts without giving me any useful information. What I suspect is happening is infinite recursion. Each Directory object creates an array of Subdirectories each of which has an array of...
15
7900
denny1824
by: denny1824 | last post by:
I have a working website. I copied all the files to a new folder in inetpub/wwwroot and then set that folder as a Virtual Directory in IIS. I try going to that site from the new folder and i am getting a default error page. It is an aspx page that I am trying to view. If I put in a fake page name it gives a different error about that fake name not existing, which means to me that it is seeing the page I want to view but is giving an error...
0
9554
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9377
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9989
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9925
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8814
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6640
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5266
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3509
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.