Jump to content

can't delete ini file when app is running !!


Recommended Posts

  • Developers

What exactly are you doing when you get the error as that has nothing to do with your script, assuming you use the standard INIRead/Write functions.
So please share more details!

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

On 8/22/2020 at 11:15 PM, Jos said:

What exactly are you doing when you get the error as that has nothing to do with your script, assuming you use the standard INIRead/Write functions.
So please share more details!

Jos

the main goal is to import newer database files to replace with existing ones 

this is what I did in my code exactly 

;the older badabases
Local $Site_db = @LocalAppDataDir&"\PTMW\Site_db.ini"
Local $Sec_db = @LocalAppDataDir&"\PTMW\Sec_db.ini"
;-------------------------------------------
;the newer databese
Local $Site_db_tmp = @TempDir&"\ptmw\Site_db.ini"
Local $Sec_db_tmp = @TempDir&"\ptmw\Sec_db.ini"
;-------------------------------------------
If FileExists($Site_db_tmp)and FileExists($Sec_db_tmp) Then
  FileCopy($Site_db_tmp,$Site_db,1+8)
  FileCopy($Sec_db_tmp,$Sec_db,1+8) 
  FileSetAttrib($Sec_db,"+H") 
  FileSetAttrib($Site_db,"+H") 
EndIf

the code works well on windows 7 but when I test on win 10 it can't replace files and import !

Link to comment
Share on other sites

Put some error handling in there so you know what are the resulting value of the functions and @error when set.  You should learn some basic debugging techniques when you are faced with a problem.

Link to comment
Share on other sites

  • Developers
1 hour ago, AlienStar said:

and I don't know what happened to SciTE that I can't writeconsole and the error close app without detecting the reason or the error message showed on SciTE

No idea what you are on about here nut I am pretty sure we are dealing with a "pilot error" here.
Install the Full SciTE4AutoIt3 installer and run your script with F5 and see what it tells you. ;)

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Moderators

Jos,

Less of the "pilot error" please. "Chair-keyboard interface problem" is the acceptable terminology!

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

I've re-installed latest autoit version on the website which includes SciTE editor but still the same problem 

my app works fine on win 7 but when I tested on win 10 I faced this problem 

so I changed the method I import database:

clear entire sections in ini based files and read all sections from the newer ini then write to the older and it succeeded :)

; import a new $Site_db
Local $sCase = ""
Local $Site_var_tmp = StringRegExp(FileRead($Site_db_tmp), $sCase & "(?m:^).*" & "Section_" & ".*(?:\v|$)+", 3)
Local $size = UBound($Site_var_tmp)
;=======================================
;----------------------------------
;_ArrayDisplay($Site_var_tmp)
;---------------------------------
if $size>0  then
   ;-------------------------------------------
   ;delete content of $Site_db only if there a a new db in $Site_var_tmp
   Local $Site_db_var = IniReadSectionNames($Site_db)
   if UBound($Site_db_var)>0 Then
      for $ist = 1 to UBound($Site_db_var)-1
         IniDelete($Site_db,$Site_db_var[$ist])
      Next
   EndIf
   ;---------------------------------------------------------
   ; now write the new section in the based DB
   For $is = 0 to UBound($Site_var_tmp)-1
      ;----------------------------------
      Local $rslt_ex = StringSplit($Site_var_tmp[$is],"=")
      ;----------------------------------
      Local $imrtd_ID = StringReplace($rslt_ex[1],"Section_","")
      Local $imrtd_Sec = StringReplace(IniRead($Site_db_tmp,$imrtd_ID,"Section_"&$imrtd_ID,"Default Value"),"|"&$imrtd_ID,"")
      Local $imrtd_Sitenm = IniRead($Site_db_tmp,$imrtd_ID,"Sitenm_"&$imrtd_ID,"Default Value")
      Local $imrtd_Site_lnk = IniRead($Site_db_tmp,$imrtd_ID,"Site_lnk_"&$imrtd_ID,"Default Value")
      Local $imrtd_Site_usrnm = IniRead($Site_db_tmp,$imrtd_ID,"username_"&$imrtd_ID,"Default Value")
      Local $imrtd_Site_pass = IniRead($Site_db_tmp,$imrtd_ID,"password_"&$imrtd_ID,"Default Value")
      Local $imrtd_Site_dflt = IniRead($Site_db_tmp,$imrtd_ID,"Default","Default Value")
      ;----------------------------------
      Local $imprtd_data = "Section_"&$imrtd_ID&"="&$imrtd_Sec&@CRLF& _
               "Sitenm_"&$imrtd_ID&"="&$imrtd_Sitenm&@CRLF& _
               "Site_lnk_"&$imrtd_ID&"="&$imrtd_Site_lnk&@CRLF& _
               "username_"&$imrtd_ID&"="&$imrtd_Site_usrnm&@CRLF& _
               "password_"&$imrtd_ID&"="&$imrtd_Site_pass&@CRLF& _
               "Default"&"="&$imrtd_Site_dflt
      ;----------------------------------
      $sCase = ""
      Local $skeyword = "category_"&$imrtd_ID
      Local $cat_imprtd_arr = StringRegExp(FileRead($Site_db_tmp), $sCase & "(?m:^).*" & $skeyword & ".*(?:\v|$)+", 3)
      ;----------------------------------
      if UBound($cat_imprtd_arr)>0 Then
         ;----------------------------------
         For $idlS = 0 to UBound($cat_imprtd_arr)-1
            ;----------------------------------
            Local $imprtd_cat0 = StringReplace($cat_imprtd_arr[$idlS],"category_"&$imrtd_ID&"=","")
            Local $imprtd_cat_ex = StringSplit($imprtd_cat0,"|")
            Local $imprtd_cat = $imprtd_cat_ex[1]
            Local $imprtd_cat_ID = StringRegExpReplace($imprtd_cat_ex[2], "^\R+|\R+$|\R\K\R+", "")
            ;ConsoleWrite("$Del_Site_cat = "&$Del_Site_cat&" - "&$Del_Site_cat_ID&@CRLF)
            ;----------------------------------
            if $imprtd_categs = "" Then
               $imprtd_categs = "category_"&$imrtd_ID&"="&$imprtd_cat&"|"&$imprtd_cat_ID
            Else
               $imprtd_categs = $imprtd_categs&@CRLF&"category_"&$imrtd_ID&"="&$imprtd_cat&"|"&$imprtd_cat_ID
            EndIf
         Next
         ;----------------------------------
      EndIf
      ;----------------------------------
      $imprtd_data = $imprtd_data&@CRLF&$imprtd_categs
      ;----------------------------------
      IniWriteSection($Site_db,$imrtd_ID,$imprtd_data)
      ;----------------------------------
   Next
   ;----------------------------------
   Listview()
   ;----------------------------------
Else
   ;----------------------------------
   MsgBox($MB_ICONWARNING,"تنبيه","There is no sites to import")
EndIf

 

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...