Click to See Complete Forum and Search --> : Questions regarding pointers to files
paradoxresolved
November 29th, 2005, 10:36 AM
Suppose I have the entire path name of a file on a network. How would I:
1) obtain a pointer to that file,
and then use that pointer to. . .
2) change the name of the file
and/or
3) open the file using its default application.
The primary task is to open a file containing a scanned document, peruse the file, and rename it according to the contents, (in addition to other tasks involving the file). So, I'd like to create a small application that assists in this. I have potentially hundreds of these file to do each a day.
Thanks for the help.
treuss
November 29th, 2005, 10:55 AM
The answer to your question depends very much on
- what OS you are using (file handling is done mostly through the OS API)
- what Network are we talking about, i.e. is the file accessed via NFS, FTP, CIFS, ...
In any case, C++ is probably one of the worst choices for such a task. Languages like PERL or Shell/Cmd scripts are typically much more suited, i.e. you will have a working implementation in much quicker time.
paradoxresolved
November 29th, 2005, 11:03 AM
Sadly, I don't know either of those languages. . . :,(
I know next to nothing about networks also. I was hoping there was a simple means of openning, closing and changing names of files on a network drive.
*sigh*
hmmm. . . by OS, I'm assuming you're talking about the computer I'm on. The OS is Windows 2000 professional. Is these an easy way to find out about the network stuff (i.e. FTP, etc.)?
treuss
November 29th, 2005, 11:41 AM
The network protocol you are using can typically told by the way you are accessing the files. If you are accessing them via a UNC name like \\server\service\dir1\dir2\filename, than the protocol is CIFS (formerly called SMB). If you access them via an URL, the protocol is the first part of the URL, e.g. ftp://ftp.codeguru.com/codeexamples/test.cc is using the FTP protocol.
Most likely you are talking about CIFS and should find out the API functions that windows provides for accessing and renaming files.
paradoxresolved
November 29th, 2005, 11:51 AM
Yeah, it appears to match CIFS. . .
I'll start looking for the API functions. Anyone have any ideas where to start?
Thanks for your help, treuss.
Edit: Wow. That is way outside my range of current understanding. Can anyone give me an example of acquiring a pointer to the file in Windows 2000 Professional, via a CIFS network? That would be much appreciated.
eero_p
November 30th, 2005, 01:47 AM
You don't need a pointer to run/change name of files, only name of file (with path).
Since there is no (afaik) method to change the name, you have to copy the file to new name (and delete file with old name).
Use CopyFile() or CopyFileEx() to copy the file, and DeleteFile() to delete.
You can run the file with default application by using ShellExecute().
Parameters are described in MSDN.
I hope this helps.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.