Jump to content

Recommended Posts

Posted (edited)

nope, got the phonetree.csv in my root folder, got also the test.exe (the script) there aswell & it creates a phonetree.zip thats only 1kb & is blank inside.

Using Windows XP Pro

Edited by bb01
Posted

XP Pro also here! tryed your script, before editing:

#include <_Zip.au3>

Global $sFileName=@ScriptDir & "\phonetree.zip"

Global $iOverwrite=1

Global $sZipFile=@ScriptDir & "\phonetree.zip"

Global $sFileAddName=@ScriptDir & "\phonetree.csv"

Global $sDestDir="\"

Global $iFlag=77

;create the phonetree.zip

_Zip_Create($sFileName, $iOverwrite)

;Then to add phonetree.csv to the zip

_Zip_AddItem($sZipFile, $sFileAddName, $sDestDir, $iFlag)

with no problems. Also tried with other files also.

Posted

Works for me too on Win7. What's the console output of the following:

#include <_Zip.au3>

Global $sFileName=@ScriptDir & "\phonetree.zip"
Global $iOverwrite=1
Global $sZipFile=@ScriptDir & "\phonetree.zip"
Global $sFileAddName=@ScriptDir & "\phonetree.csv"
Global $sDestDir="\"
Global $iFlag=77

;create the phonetree.zip
$r = _Zip_Create($sFileName, $iOverwrite)
ConsoleWrite(@error & " : " & $r & @CRLF)

;Then to add phonetree.csv to the zip
$r = _Zip_AddItem($sZipFile, $sFileAddName, $sDestDir, $iFlag)
ConsoleWrite(@error & " : " & $r & @CRLF)
Posted (edited)

@bbo - Perhaps (as listed at #40)

;create the phonetree.zip

_Zip_Create("\phonetree.zip",1)

should have been

;create the phonetree.zip

_Zip_Create($sZipFile,1)

;):)

Edited by TheSaint

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Posted (edited)

found the problem

it was because i had the \ before the filenames, therefore it was trying to find C:\\phonetree.zip

#include <_Zip.au3>

Global $sFileName=@ScriptDir & "phonetree.zip"
Global $iOverwrite=1
Global $sZipFile=@ScriptDir & "phonetree.zip"
Global $sFileAddName=@ScriptDir & "phonetree.csv"
Global $sDestDir=""
Global $iFlag=77

;create the phonetree.zip
$r = _Zip_Create($sFileName, $iOverwrite)
ConsoleWrite(@error & " : " & $r & @CRLF)

;Then to add phonetree.csv to the zip
$r = _Zip_AddItem($sZipFile, $sFileAddName, $sDestDir, $iFlag)
ConsoleWrite(@error & " : " & $r & @CRLF)

Once i fixed that, it now creates & inserts the file..

Didn't even realize that, till just now... Might want to add that to the header, so others don't try to do that..

Edited by bb01
Posted (edited)

@bb01

You are wrong on many levels, sorry.

1 - Your code is wrong. Print out the paths you've created above and see what they look like. You need the \ before the file names.

2 - Your original code was the source of the problem, and you would have easily figured it out if you looked at the returns and error codes from my functions. You used "\phonetree.zip" as the name of the zip file. Did you bother to look where that file was created? On my system, it was not in the script directory. Therefore your call to AddItem passed an invalid path, and an error code of 7 was returned -> 'Destination ZIP file does not exist'

Edited by wraithdu
Posted (edited)

when i had "\phonetree.zip"

it would create a blank phonetree.zip

However when i took away the "\"

It then would create the "phonetree.zip" with the phonetree.csv inside it

using this script:-

#include <_Zip.au3>

Global $sFileName=@ScriptDir & "\phonetree.zip"
Global $iOverwrite=1
Global $sZipFile=@ScriptDir & "\phonetree.zip"
Global $sFileAddName=@ScriptDir & "\phonetree.csv"
Global $sDestDir=""
Global $iFlag=77

;create the phonetree.zip
$r = _Zip_Create($sFileName, $iOverwrite)
ConsoleWrite(@error & " : " & $r & @CRLF)

;Then to add phonetree.csv to the zip
$r = _Zip_AddItem($sZipFile, $sFileAddName, $sDestDir, $iFlag)
ConsoleWrite(@error & " : " & $r & @CRLF)

I get in the console:-

>"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\testing.au3"    
0 : C:\\phonetree.zip
7 : 0
>Exit code: 0    Time: 0.336

But if i take out the "\"

So the script looks like

#include <_Zip.au3>

Global $sFileName=@ScriptDir & "phonetree.zip"
Global $iOverwrite=1
Global $sZipFile=@ScriptDir & "phonetree.zip"
Global $sFileAddName=@ScriptDir & "phonetree.csv"
Global $sDestDir="\"
Global $iFlag=77

;create the phonetree.zip
$r = _Zip_Create($sFileName, $iOverwrite)
ConsoleWrite(@error & " : " & $r & @CRLF)

;Then to add phonetree.csv to the zip
$r = _Zip_AddItem($sZipFile, $sFileAddName, $sDestDir, $iFlag)
ConsoleWrite(@error & " : " & $r & @CRLF)

then i get phonetree.zip with phonetree.csv inside it.

& the console shows:-

>"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\testing.au3"    
0 : C:\phonetree.zip
0 : 1
>Exit code: 0    Time: 0.552
Edited by bb01
Posted

Ok, that's why it's weird. Try not to run anything from the root drive. AutoIt @ScriptDir macro is inconsistent in this case. When in the root, @ScriptDir expands to 'X:\' with the trailing \. In any other directory, it expands to 'X:\some\dir' WITHOUT a trailing \. This is something YOU as a scripter have to be aware of, I cannot test for and fix that error.

Posted

And if you don't believe or understand wraithdu, then check the Help file - which in your case is probably mandatory reading at this point! ;)

(i.e. you'll gain more understanding of what you are doing, which currently is pretty basic errors)

Another recommendation for troubleshooting, is to use the occasional, prudent & temporary Msgbox to check on values for variables ... especially for paths.

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Posted

I have no idea how you got a copy of the UDF with 'Local $' in it. The ones I have posted / updated do not have such errors. Get the updated copy anyway. And remove the UDF from your post above, it's large and unnecessary.

Awesome

Skysnake

Skysnake

Why is the snake in the sky?

Posted

i wasnt saying wraithdu was wrong, i was trying to state that no matter how i did it, it just would not work right.. now that i've moved the folder & files it's working fine..

However i needed to do it, so that it would run at the root, as the network its on is the root dir.

Anyway thanks for the help guys. & wraithdu it does work perfectly now.. Thank you.

Posted

Your post is pretty useless. All I can say is I don't get that error, at all. You're going to need to post some reproducible code with specific instructions.

  • 1 month later...
Posted (edited)

Has anybody had issues with _Zip_UnzipAll when "Hide extensions for known file types" is enabled in explorer?

It was unzipping the files fine, but I kept getting the failure to extract error.

I found out it was because the check if the file exists was returning 0

(this line)

If FileExists($sDestPath & "\" & $oNS.Items.Item($oNS.Items.Count - 1).Name) Then

From what i could see when you have "Hide extensions for known file types" enabled it only was returning "Uninstall" instead of "Uninstall.exe"

To fix this temporarily I am getting the filename out out of the path instead

(like this)

$testfilesourcepath = $oNS.Items.Item($oNS.Items.Count - 1).path
$testfiledestpath = $sDestPath & "\" & StringTrimLeft($testfilesourcepath, StringInStr($testfilesourcepath, "\" , 0 , -1))
If FileExists($testfiledestpath) Then
Edited by ACalcutt

Andrew Calcutt

Http://www.Vistumbler.net

Http://www.TechIdiots.net

Its not an error, its a undocumented feature

Posted

Nice one...

I'm glad someone decided to solve that $CmdLine bug in the original UDF.

but... i have a problem...

I was using the original zip UDF and to add all files inside a folder I used _Zip_AddFolder, but this option is no longer available in your version, instead I have the option _Zip_AddItem, the probem with this is that with _Zip_AddFolder I can add all the files inside a folder without adding the folder itself but with _Zip_AddItem the folder is added too... Any Ideas on how to solve this? What I want is to add all files inside a folder without adding the folder itself.

"Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life." - Terry Pratchett.

Posted (edited)

You'll need to loop through your source files and add them individually to the new archive. The UDF does not support adding the contents of a folder. Please read the UDF header for my explanation (a good place to start anyway).

Edited by wraithdu
  • 1 month later...

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
  • Recently Browsing   0 members

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