473,385 Members | 1,333 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

help in filesystem object

284 100+
i want to copy a specific file and paste into another folder
i am using the following code

Expand|Select|Wrap|Line Numbers
  1.  '' getting the required file to be copied 
  2. fso.GetFile "D:\Data\smeb_Data.MDF"
  3.  
  4. '' creating newfolder 
  5. If fso.FolderExists("H:\Backup") Then
  6. Else
  7. fso.CreateFolder "H:\Backup"
  8. End If
  9.  
  10. ''pasting the file
  11. fso.CopyFile "H:\Backup\smeb_Data.MDF"
  12. Exit Sub
  13.  
  14.  

when i run this code i get errror
"argument not optional "

what chages i have to made in it
any help

i also want to copy more than one files and it should be pasted with
out promting that file already exists
Mar 23 '08 #1
6 1423
jg007
283 100+
i want to copy a specific file and paste into another folder
my VB is a bid lousy but this worked for me -

Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3.       '' getting the required file to be copied 
  4.  
  5.         Dim fso As System.IO.FileInfo = FileIO.FileSystem.GetFileInfo("D:\Data\smeb_Data.MDF")
  6.  
  7.  
  8.         ' creating newfolder 
  9.         If FileIO.FileSystem.DirectoryExists("H:\Backup") Then
  10.         Else
  11.             FileIO.FileSystem.CreateDirectory("H:\Backup")
  12.  
  13.         End If
  14.  
  15.         ''pasting the file
  16.         fso.CopyTo("H:\Backup\" & fso.Name)
  17.  
  18.  
  19.  
Mar 23 '08 #2
muddasirmunir
284 100+
there is something wrong in line

Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim fso As System.IO.FileInfo = FileIO.FileSystem.GetFileInfo("D:\Data\smeb_Data.MDF")
  3.  
vb is showing it as red colour and giving error
"expected end of statement"





my VB is a bid lousy but this worked for me -

Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. '' getting the required file to be copied 
  4.  
  5. Dim fso As System.IO.FileInfo = FileIO.FileSystem.GetFileInfo("D:\Data\smeb_Data.MDF")
  6.  
  7.  
  8. ' creating newfolder 
  9. If FileIO.FileSystem.DirectoryExists("H:\Backup") Then
  10. Else
  11. FileIO.FileSystem.CreateDirectory("H:\Backup")
  12.  
  13. End If
  14.  
  15. ''pasting the file
  16. fso.CopyTo("H:\Backup\" & fso.Name)
  17.  
  18.  
  19.  
Mar 23 '08 #3
jg007
283 100+
are you entering it all as one line?, also it is VB.net and I noticed later that you are using VB 6
Mar 23 '08 #4
lotus18
866 512MB
Try:
Expand|Select|Wrap|Line Numbers
  1. Dim fso As New FileSystemObject
  2. Dim s As String
  3.  
  4. s="D:\Data\smeb_Data.MDF"
  5.  
  6. If fso.FolderExists("H:\Backup")=False Then
  7.      fso.CreateFolder "H:\Backup"
  8. End If
  9.  
  10. fso.CopyFile s, "H:\Backup\smeb_Data.MDF"
  11. Exit Sub
  12.  
  13.  
Line 10, argument is not optional because you didn't specify the path to paste the file.

Rey Sean
Mar 23 '08 #5
muddasirmunir
284 100+
thanks this code works



Try:
Expand|Select|Wrap|Line Numbers
  1. Dim fso As New FileSystemObject
  2. Dim s As String
  3.  
  4. s="D:\Data\smeb_Data.MDF"
  5.  
  6. If fso.FolderExists("H:\Backup")=False Then
  7. fso.CreateFolder "H:\Backup"
  8. End If
  9.  
  10. fso.CopyFile s, "H:\Backup\smeb_Data.MDF"
  11. Exit Sub
  12.  
  13.  
Line 11, argument is not optional because you didn't specify the path to paste the file.

Rey Sean
Mar 23 '08 #6
lotus18
866 512MB
Glad we could help : )

Rey Sean
Mar 23 '08 #7

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

Similar topics

0
by: fishfry | last post by:
I'm using a TreeModel to represent a filesystem directory tree for presentation by a JTree. The first level of the directory appears fine, but when I click on any of the little triangles to expand...
9
by: Peter Hansen | last post by:
The term "mock filesystem" refers to code allowing unit or acceptance tests to create, read and write, and manipulate in other ways "virtual" files, without any actual disk access. Everything is...
7
by: Catherine Jones | last post by:
Hi all we are getting active x component can not create object (Error No. 16) while creating an instance of File System Object in ASP client side script. Could you plz help us in solving this...
2
by: Jeff Davis | last post by:
I have virtual hosted users on a server and some of them have a postgresql database. I'm concerned about the outside possibility that a user could create an infinite loop and fill up the partition...
8
by: Daz | last post by:
Hi Everyone. I am sturggling trying to find out a way in which I can delete a 'path' object. I may not need to delete it, however, I need to overwrite it. The function I am trying to code,...
3
by: Milagro | last post by:
Hello Everyone, I'm trying to debug someone elses php code. I'm actually a Perl programmer, with OO experience, but not in php. The code is supposed to upload a photo from a form and save it...
1
by: teejayem | last post by:
Hi. Hopefully somebody out there will be able to help me! I am using VB.Net and I am trying to find out logical disk information. I would like to be able to find the drive letters of any...
5
by: GaryE | last post by:
Hello: I am having trouble linking a couple of files using the boost::filesystem. I am using MSVC 6.0. Here is an abbreviated version of my problem: foo.h: #ifndef __FOO_ #define...
4
by: cmdolcet69 | last post by:
I have the below code that calls a function to delete a file that i added to a listview node. What happens is that that file doesn;t delete. Please help me out. I have included the event handler...
2
by: grotgod | last post by:
Hello; I have a pretty interesting problem here. I read an xml file from the server using the fileSystem object. However...the text "magically" turn into Chinese characters. If I take a look...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.