473,385 Members | 1,409 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.

Copy Files to a network drive in Win2000

I recently was asked to write a program that moved files to certain places
on a network drive based on what the files were (mainly filenames since the
files are mostly Office documents of various types). I have tried rename()
but it seems to have problems with moving things across file systems, and I
have had problems with system("cmd.exe /c move file1.doc file2.doc") and
various like comands with it not moving all the files all the time (I'm not
sure why it does it sometimes and not others). I don't want to have to move
the file by copying it bit by bit to another file and deleting the original,
though I fear that will be the only way to do it. If there are any serious
inconsistancies it is because I couldn't find the code in the few seconds
before typing this, and I am running from memory. Thanks in advance.
Nathaniel
Nov 13 '05 #1
3 5190
On Sat, 6 Sep 2003 14:02:12 -0400, in comp.lang.c , "Nathaniel
Wingard" <Pa******@hotmail.com> wrote:
I recently was asked to write a program that moved files to certain places
on a network drive based on what the files were


There's no sensible portable way to do this in C. As you found out,
rename() may or may not do it, its implementation specific.

One portable way would be to open each file in binary mode, copy its
contents to a new file at the new location, then remove() the old one.
This is likely to be pretty inefficient but would work.

However its very likely your OS provides more sensible ways to do this
- for instance a cursory glance at the Win32 API suggests
MoveFileEx(). By the way it took me about 30 seconds to find this, and
I strongly recommend searching your local documentaiton before going
to usenet, its usually quicker for trivial questions. :-)

Also, C is not really the best language for it TBH. Perl might be
better. Learn perl, its worth it.

--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>
Nov 13 '05 #2

"Nathaniel Wingard" <Pa******@hotmail.com> wrote in message
news:bj***********@msunews.cl.msu.edu...
I recently was asked to write a program that moved files to certain places
on a network drive based on what the files were (mainly filenames since the files are mostly Office documents of various types). I have tried rename() but it seems to have problems with moving things across file systems, and I have had problems with system("cmd.exe /c move file1.doc file2.doc") and
various like comands with it not moving all the files all the time (I'm not sure why it does it sometimes and not others). I don't want to have to move the file by copying it bit by bit to another file and deleting the original, though I fear that will be the only way to do it. If there are any serious
inconsistancies it is because I couldn't find the code in the few seconds
before typing this, and I am running from memory. Thanks in advance.
Nathaniel


Try comp.os.ms-windows.programmer.win32

--
Jeff
Nov 13 '05 #3
Unfortunately I did look in my references, wich after knowing the name of
the function took me a few minutes to find (I really don't know how this is
organized), but it looks as if that function should do what I want it to,
thanks. As for Perl, I thought about it, but IIRC it is an interpreted
language and I really don't want to put a perl interpreter on all the
machines so that I can run it. Maybe some other day.

"Mark McIntyre" <ma**********@spamcop.net> wrote in message
news:r2********************************@4ax.com...
On Sat, 6 Sep 2003 14:02:12 -0400, in comp.lang.c , "Nathaniel
Wingard" <Pa******@hotmail.com> wrote:
I recently was asked to write a program that moved files to certain placeson a network drive based on what the files were


There's no sensible portable way to do this in C. As you found out,
rename() may or may not do it, its implementation specific.

One portable way would be to open each file in binary mode, copy its
contents to a new file at the new location, then remove() the old one.
This is likely to be pretty inefficient but would work.

However its very likely your OS provides more sensible ways to do this
- for instance a cursory glance at the Win32 API suggests
MoveFileEx(). By the way it took me about 30 seconds to find this, and
I strongly recommend searching your local documentaiton before going
to usenet, its usually quicker for trivial questions. :-)

Also, C is not really the best language for it TBH. Perl might be
better. Learn perl, its worth it.

--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>

Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Jonathan | last post by:
Hello, I want to install the current version 4.0.13 of MySQL on a Win2000 machine in a directory different to the default (C:\mysql). It should be a network drive, as this is backed up by our IT...
11
by: Mike | last post by:
I want to be able to copy a directory of files (all .HTM files) from a network drive to a local drive on the machine c:\HTMFiles , How can i do that? I tried File.Copy(source, dest) but i need...
1
by: PRM | last post by:
Hi I have an ASp.net application using C#. I need to copy a file present on the web server machine to a remote machine on the network. Although this seems to be a trivial matter I am having...
0
by: PRM | last post by:
Hi I have an ASp.net application using C#. I need to copy a file present on the web server machine to a remote machine on the network. Although this seems to be a trivial matter I am having...
3
by: Marcel | last post by:
Hello, I have a problem with accessing files on other computers in my network. The network is a Windows 2000 workgroup network and I have administrator rights.... This works (from the directory...
2
by: 1388-2/HB | last post by:
On a W2K3 box running IIS 6 I have a web app that implements Forms Authentication mixed with AD (the login page autheticates users against AD & impersonates them with each page request). This...
4
by: sajid_yusuf | last post by:
Hi I am trying to develop a Windows service in VB.NET which has timer enabled and keeps checking a folder (or group of folders) for any new file or changed files. As soon as it detects any new...
25
by: Andy_Khosravi | last post by:
I just recently changed my database that I'm running from a monolithic DB to a split FE/BE. The front end resides on the client machine and the BE resides on a network drive. I'm experimenting with...
1
by: =?Utf-8?B?UVNJRGV2ZWxvcGVy?= | last post by:
Using .NET 2.0 is it more efficient to copy files to a single folder versus spreading them across multiple folders. For instance if we have 100,000 files to be copied, Do we copy all of them to...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.