Jump to content

FileWrite problem when the path is too long....


Recommended Posts

Hi evrery body ,

I will explain my problem !

I have a part of code like this :

case $Button12
         GuiCtrlSetData($input1,FileOpenDialog("Recherche programme",@ScriptDir,"All (*.*)",3))
case $Button13
         GuiCtrlSetData($input2,FileOpenDialog("Recherche programme",@ScriptDir,"All (*.*)",3))
case $Button14
         GuiCtrlSetData($input3,FileOpenDialog("Recherche programme",@ScriptDir,"All (*.*)",3))
case $Button15
         GuiCtrlSetData($input4,FileOpenDialog("Recherche programme",@ScriptDir,"All (*.*)",3))

where I store a path of a file in an input (for a GUI) , even here all work well and all is been displayed,

But a little afar in my code I have a function to save this path in a file like this :

Filewrite($file,"file1path="&GuiCtrlRead($input1))

It's here the problem if the path is like C:xxxxxxfile.exe it's working perfeclty but's if its C:xxxxxxxxxxxxxxxxfile.exe it's doesnt work my file is blank o_o !

the result depends on the size of the path !!!

i never have this problem before ! and if some people has an idea it's welcome ^^' !!!

Thank you so much !

Ps : sorry for my english in french :-* !

Link to comment
Share on other sites

How long is the path name and file name together? Windows has a limit of 260 characters unless you use Unicode paths ("?")

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

for exemple a path  who doesnt work is : "C:Usersgroma_000Desktopfolders1folderRessourcefile.txt" this doesnt work but : "C:Usersgroma_000Desktopfolders1file.txt" work  :x !

i think i have not rise over 260 character ..

thanks for help !

Link to comment
Share on other sites

You should probably do something other than trying to read the path out of, what I'm assuming is, an input control. Why not just use the return from FileOpenDialog to set a variable, and use that variable later in the script? That way you know what's in the variable, and the path hasn't been changed by altering the control's contents.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Works For me it

Global $i2

Func _CreateDirs()
For $i = 1 to 10

$i2 &= "1\"

DirCreate(@DesktopDir & "\" & $i2)
Next

Return $i2

EndFunc;_CreateDirs

$sFileFullPath = @DesktopDir & "\" & _CreateDirs()

FileWrite($sFileFullPath & "\AAA.txt", "Hello")

And also works

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

$hGUI = GUICreate("",500,500,-1,-1)
$hLabel = GUICtrlCreateLabel("",0,0,500,500,0x01+0x0200)
GUICtrlSetFont(-1,12,"","","Arial",5)
GUICtrlSetBkColor(-1,0x0000FF)
GUICtrlSetColor(-1,0xFFFFFF)

GUISetState(@SW_SHOW)


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hLabel
            $sSelectedFile = FileOpenDialog("Select a file",@DesktopDir & "\","All (*.*)",3)
            GUICtrlSetData($hLabel,$sSelectedFile)

    EndSwitch
WEnd
Edited by GordonFreeman
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...