Jump to content

File open from a specifc dir ?


 Share

Recommended Posts

My Requirement:

I will get the filename during the runtime. Using that file name , I need to search for the availabilit of the file in a particular dir, and if it is avialable I need to open that file from that dir.

I have the dir name in a variable , and the file name in another variable, I have used $file3=FileOpen($lib_path & $file2,0)

I am getting an error message . How can i get this resolved ??

Link to comment
Share on other sites

File Open returns '-1' , we cannot open the file. I had tried this also..

Hm.. maybe because the file does not exist? File? Exist? FileExists() !!

Cheers

Kurt

Edited by /dev/null

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

lol

maybe it is a read only access issue ?

well, no. He opened the file in "Read Mode". So, it would be rather a "write only access" issue :whistle:

Cheers

Kurt

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

I am not able to open only this file..

The file exists in the dir.. also I just need to open that file and copy its contents to another file , hence read only mode should be sufficient I guess ..

how do I resolve this issue ??

Link to comment
Share on other sites

how do I resolve this issue ??

Maybe you can't open it because some other process opened it before. The information you provided is not enough the figure out what's going wrong.

So, where is the file coming from?

What's the content of $lib_path and $file2?

Maybe you should try: FileCopy().

Cheers

Kurt

Edited by /dev/null

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

  • Moderators

I cannot use filecopy bcoz. I have to append the content.

I have attached the script.. for u r reference..

That is script is super confusing... Can you just say what it is step by step that you are trying to accomplish and maybe we can come up with a better, "faster", and more stable solution?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Following is the content

Connection_Manager

ait_connection

Connection_Manager1

Connection_Manager2

Connection_Manager3

Connection_Manager4

Connection_Manager5

Connection_Manager6

Connection_Manager7

Connection_Manager8

Connection_Manager9

Link to comment
Share on other sites

I cannot use filecopy bcoz. I have to append the content.

I have attached the script.. for u r reference..

erm, Vinod. Your code is FULL of errors. You're mixing $file1, $file2, $file3 etc. as you like. This CANNOT work. I would suggest you read the code thoroughly and fix those problems first.

Now to your first question.

$file4=FileOpen($lib_path & $file2,0)

Does not work, because THAT file does not exist. $lib_path = "C:\test\lib\" and $file2 = "ait_connection", so you are trying to open the file "C:\test\lib\ait_connection", which most certainly does not exist!

Cheers

Kurt

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

If the file does not exist, the search should fail, but search is successful . Only the issue is with Fileopen.

Rest of the correction I had done..

O.K. post the corrected code.

Cheers

Kurt

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

Here is the file...

O.K., so why don't you use FileExists()? Your whole FileFindFlieFirst/FileFindFileNext is useless is you're not using wildcards or traversing directories.

Then, what's the output of " MsgBox(0, "filepath", $temp)" in your script and does that file exist?

Maybe you should provide a textual description what you want to do. Based on your code it's really hard to figure out and then to find a logical error.

AND then what's this??

$file5= FileRead("$lib_path & $file4,FileGetSize($lib_path & $file4)")

You can't use double quotes here!! And you can't use $file4 here. That's a file handle. And you don't need the whole FileGetSize() thing.

Cheers

Kurt

Edited by /dev/null

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...