473,503 Members | 2,163 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

filesystemobject.movefolder?

lee123
556 Contributor
why is this so hard to do. i have alot of books that have exaples of how to do these things but when i try the exaples they never work i have a previous post on "copying files" some of the other guys help on this one and i tried to do the same thing with the "movefile" but it never worked as you can see the "filesystemobject" is hard to accomplish for me because this "Movefolder" event falls in this category the code i have i have used for the copyfolder event right here:

Expand|Select|Wrap|Line Numbers
  1. Dim fso As New Scripting.FileSystemObject
  2. Dim fld As Folder
  3. Set fld = fso.GetFolder(txtSourceOfFolder)
  4. fld.Copy (txtDestinationOfFile)
this is to copy the folder. How can i use this to move the folder to another folder of my choosing. because i have tried this:

Expand|Select|Wrap|Line Numbers
  1. Dim fso As New FileSystemObject
  2. Dim fldr As Folder
  3. Set fso = fso.GetFolder(TxtSource.Text)
  4. fldr.Move (TxtDestination.Text)
  5. MsgBox "Moved"
so can someone tell me or explain to me why it doesn't work. is there something There not explaining in these books? or is this "filesystemobject" a hard cookie to crack.

lee123
Sep 7 '08 #1
12 5864
jg007
283 Contributor
not sure if this was just a miss type but you are not assigning the fldr variable before trying to use it

your code -

Expand|Select|Wrap|Line Numbers
  1. Dim fso As New FileSystemObject
  2. Dim fldr As Folder
  3. Set fso = fso.GetFolder(TxtSource.Text)
  4. fldr.Move (TxtDestination.Text)
  5. MsgBox "Moved"
works as

Expand|Select|Wrap|Line Numbers
  1. Dim fso As New FileSystemObject
  2. Dim fldr As Folder
  3. Set fldr= fso.GetFolder(TxtSource.Text) ' <------ note the change here 
  4. fldr.Move (TxtDestination.Text)    
  5. MsgBox "Moved"
Sep 7 '08 #2
jg007
283 Contributor
it also helps if you post any errors you receive as in this case I would have expected to see -

' Warning 1 Variable 'fldr' is used before it has been assigned a value. A null reference exception could result at runtime.


I'm not to sure of the exact terms but fso is just a pointer to the filesystemobject and you then use getfolder to assign a specific folder to fldr , once fldr is pointed at a folder you can user the function to move it.
Sep 7 '08 #3
lee123
556 Contributor
hey there, ok it was a miss type on my part, i got so fustrated doing it so many ways that i forgot to change it back to "fldr" and the error I'm getting is "Permssion Denied" and it keeps pointing to this part of the code:

Expand|Select|Wrap|Line Numbers
  1. fldr.Move (TxtDestination.Text)
is it because there are files in this folder? or I can't express the code this way. How Can I do This?

lee123
Sep 7 '08 #4
lee123
556 Contributor
Oh Yea I have tried it this way too but keep getting an error: "Compile Error: Argument not Optional"

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdMove_Click()
  2. Dim fso As New FileSystemObject
  3. Dim fldr As Folder
  4. Set fldr = fso.MoveFolder(TxtSource.Text) <----- I changed it here
  5. fldr.Move (TxtDestination.Text)
  6. MsgBox "Moved"
  7. End Sub
and it points to this part of the code:

Expand|Select|Wrap|Line Numbers
  1. Set fldr = fso.MoveFolder(TxtSource.Text) <-----Where Bolded
in the book i have this is what it says to do.

lee123
Sep 7 '08 #5
ubentook
58 New Member
MoveFolder requires two arguments...
fso.MoveFolder(Source, Destination)

Move requires one argument...
fldr.Move(Destination)


Oh Yea I have tried it this way too but keep getting an error: "Compile Error: Argument not Optional"


and it points to this part of the code:
Expand|Select|Wrap|Line Numbers
  1. Set fldr = fso.MoveFolder(TxtSource.Text) <-----Where Bolded
lee123
Sep 8 '08 #6
lee123
556 Contributor
So what are you saying.....My way won't Work? or Can't work the way I want it to?

lee123
Sep 8 '08 #7
ubentook
58 New Member
The answer is... Yes
Sep 8 '08 #8
lee123
556 Contributor
So How Would you Go about Doing this?

lee123
Sep 8 '08 #9
!NoItAll
297 Contributor
I don't believe move or movefolder will work across drives if that's what you are trying to do.
Sep 8 '08 #10
lee123
556 Contributor
is there a function that will? for example move one forder (lets say in C:\) to another (lets say in D:\)

lee123
Sep 8 '08 #11
ubentook
58 New Member
Copy the folder to the other drive then delete the original folder...

Sub MoveAndConfuse()
Dim fso As Scripting.FileSystemObject
Dim fldr As Scripting.Folder
Set fso = New Scripting.FileSystemObject
Set fldr = fso.GetFolder("C:\Documents and Settings\user\My Documents\FolderName")
fso.CopyFolder fldr.Path, "F:\Scotch Tape\"
fldr.Delete
Set fldr = Nothing
Set fso = Nothing
End Sub
Sep 8 '08 #12
lee123
556 Contributor
Thank You : UBentToo, for that it works.. this "filesystemobject" is hard to figureout but i have learned alot from it thanks again.

lee123
Sep 8 '08 #13

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

Similar topics

1
1578
by: SjeekSpier | last post by:
I found in the google newsgroup there was a discussion about the movefolder method. But that thread isn't on the newsserver any more. So I want to reopen it. I already know that there is a...
5
4038
by: John Dewbert | last post by:
*** post for FREE via your newsreader at post.newsfeed.com *** Hello, I have trouble passing a folder object (from a FileSystemObject) to a sub procedure. Consider the following code: ...
3
2098
by: Steve | last post by:
Hi all, FileSystemObject question... I'm trying to check if files exist or not, but the files are not sitting on the same server as our Intranet. Basically we have about 5000 photos in a...
2
2160
by: Sean S - Perth, WA | last post by:
Hi all, If I create a FileSystemObject Object is it appropriate to reuse it to perform operations on different files/folders? Or should I create a new FileSystemObject Object for each file and...
9
3888
by: kermit | last post by:
I keep seeing that you can use the FileSystemObject in either VB script, or Javascript on an aspx page. I added a refrence to the scrrun.dll I added importing namespaces for 'System.Object',...
2
4012
by: Luis Esteban Valencia | last post by:
I'm trying to write a little VB.NET script in an ASP.NET web page that will create folders, move files, etc... pretty much everything you can expect to do using the FileSystemObject library. Is...
2
13150
by: deko | last post by:
Why am I getting: "Error Number 70: Permission denied" when trying to move a folder with the Microsoft Scripting Runtime? Is there some security setting I don't know about? Platform: Windows...
1
17070
by: G Gerard | last post by:
Hello I am using the FileSystemObject to copy files on a computer Dim MyObject as Object
3
1844
by: nagmvs | last post by:
hello I have a problem with FileSystemObject in Vb Suppose i want to declare as Dim fs As New FileSystemObject, when i type New After that i can't see FileSystemObject in derived DropDownList. ...
0
7205
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,...
0
7093
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...
0
7287
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7468
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5023
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
3170
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1521
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
747
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
401
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.