Saving over existing files doesn't change the modified date

Just starting out? Need help? Post your questions and find answers here.
User avatar
marcoagpinto
Addict
Addict
Posts: 939
Joined: Sun Mar 10, 2013 3:01 pm
Location: Portugal
Contact:

Saving over existing files doesn't change the modified date

Post by marcoagpinto »

Hello!

When I save over existing files, such as PNGs (images?) and others, it doesn't change the modified date in the files properties on the HDD.
Last edited by marcoagpinto on Fri Mar 24, 2017 11:53 am, edited 1 time in total.
normeus
Enthusiast
Enthusiast
Posts: 414
Joined: Fri Apr 20, 2012 8:09 pm
Contact:

Re: Saving over existing files doesn't change the modified d

Post by normeus »

More than likely you are not saving the file where you think it should go. ( windows temp path or APP path )
look at your filepath or filename before saving file:

Code: Select all

debug fliepath$
Norm.
google Translate;Makes my jokes fall flat- Fait mes blagues tombent à plat- Machte meine Witze verpuffen- Eh cumpari ci vo sunari
User avatar
marcoagpinto
Addict
Addict
Posts: 939
Joined: Sun Mar 10, 2013 3:01 pm
Location: Portugal
Contact:

Re: Saving over existing files doesn't change the modified d

Post by marcoagpinto »

normeus wrote:More than likely you are not saving the file where you think it should go. ( windows temp path or APP path )
look at your filepath or filename before saving file:

Code: Select all

debug fliepath$
Norm.
Well, I open a file selector from my code and choose the files.

Then, when I write over existing ones, the "modified" is still months ago when I saved them for the first time.
Fred
Administrator
Administrator
Posts: 16618
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Saving over existing files doesn't change the modified d

Post by Fred »

Please always post a code snippet showing the issue, thank you.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: Saving over existing files doesn't change the modified d

Post by ts-soft »

I think, you are saved in virtualstore?
If so, you have to write with adminright or you change the path, in a none secure location.
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
marcoagpinto
Addict
Addict
Posts: 939
Joined: Sun Mar 10, 2013 3:01 pm
Location: Portugal
Contact:

Re: Saving over existing files doesn't change the modified d

Post by marcoagpinto »

Fred wrote:Please always post a code snippet showing the issue, thank you.
Freddy, my brother, sorry.

Here is the snippet.

If you save a file and then save again over it, the modified file properties in the HDD are always the first one it was saved:

Code: Select all

  #WINDOW_MAIN=1
  #WINDOW_MAIN_CANVAS=2
  #SCREEN_BUFFER=3
    
  UsePNGImageDecoder()
  UsePNGImageEncoder()
  
  OpenWindow(#WINDOW_MAIN,0,0,640,480,"Saving file bug in modified properties")
  CanvasGadget(#WINDOW_MAIN_CANVAS,10,10,250,250)

  file$=SaveFileRequester("Save background image", "", "Images (.png)|*.png", 0)
  
  If file$<>""
    ; Add extension if none is written (".png")
    If LCase(Right(file$,4))<>".png" : file$+".png" : EndIf
    
    ; Grab image
    CreateImage(#SCREEN_BUFFER, 250, 250)
    StartDrawing(ImageOutput(#SCREEN_BUFFER))
      DrawImage(GetGadgetAttribute(#WINDOW_MAIN_CANVAS,#PB_Canvas_Image),0,0)
    StopDrawing()    
    
    ;   Save image        
    If SaveImage(#SCREEN_BUFFER,file$,#PB_ImagePlugin_PNG)=#False
      MessageRequester("Error", "Can't save background image.")
    EndIf
    
  EndIf
User avatar
Bisonte
Addict
Addict
Posts: 1226
Joined: Tue Oct 09, 2007 2:15 am

Re: Saving over existing files doesn't change the modified d

Post by Bisonte »

On Win10 is all at normal state. Modified date is always changed if I overwrite it.
You have to update the explorer view before you get the properties from the contextmenu ...
Sometimes the explorer didn't update it by himself... so a manually update must be made.
PureBasic 6.04 LTS (Windows x86/x64) | Windows10 Pro x64 | Asus TUF X570 Gaming Plus | R9 5900X | 64GB RAM | GeForce RTX 3080 TI iChill X4 | HAF XF Evo | build by vannicom​​
English is not my native language... (I often use DeepL to translate my texts.)
User avatar
Thunder93
Addict
Addict
Posts: 1788
Joined: Tue Mar 21, 2006 12:31 am
Location: Canada

Re: Saving over existing files doesn't change the modified d

Post by Thunder93 »

No issue here with the snippet. The re-saving of the png image causes every-time the update to the file modified date.

ts-soft might be right? I wonder if your changes are being done in %LOCALAPPDATA%\VirtualStore
ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley
User avatar
marcoagpinto
Addict
Addict
Posts: 939
Joined: Sun Mar 10, 2013 3:01 pm
Location: Portugal
Contact:

Re: Saving over existing files doesn't change the modified d

Post by marcoagpinto »

Buaaaaaa... what is a virtual store?

I simply save the files in the HDD.

What is wrong with saving files in the HDD?

Shouldn't the properties be updated automatically?

I am using Windows 10.
User avatar
Thunder93
Addict
Addict
Posts: 1788
Joined: Tue Mar 21, 2006 12:31 am
Location: Canada

Re: Saving over existing files doesn't change the modified d

Post by Thunder93 »

If you have the file properties dialog up, and you do overwrite. The file properties dialog information won't automatically update. You have to close and re-visit the file properties to have the updated information.

However even w/Windows 10, you overwrite the modified date information is updated correctly. You just re-visit this file properties again and compare.

Regarding VirtualStore, http://en.wikipedia.org/wiki/User_Accou ... l#Features
ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley
User avatar
Thunder93
Addict
Addict
Posts: 1788
Joined: Tue Mar 21, 2006 12:31 am
Location: Canada

Re: Saving over existing files doesn't change the modified d

Post by Thunder93 »

You could also use the following to verify this;

Code: Select all

#WINDOW_MAIN=1
#WINDOW_MAIN_CANVAS=2
#SCREEN_BUFFER=3


UsePNGImageDecoder()
UsePNGImageEncoder()

Procedure.s Main()
  Static file$
  
  OpenWindow(#WINDOW_MAIN,0,0,640,480,"Saving file bug in modified properties")
  CanvasGadget(#WINDOW_MAIN_CANVAS,10,10,250,250)
  
  If file$ = ""
    file$=SaveFileRequester("Save background image", "", "Images (.png)|*.png", 0)
  EndIf
  
  
  If file$<>""
    ; Add extension if none is written (".png")
    If LCase(Right(file$,4))<>".png" : file$+".png" : EndIf
    
    ; Grab image
    CreateImage(#SCREEN_BUFFER, 250, 250)
    StartDrawing(ImageOutput(#SCREEN_BUFFER))
    DrawImage(GetGadgetAttribute(#WINDOW_MAIN_CANVAS,#PB_Canvas_Image),0,0)
    StopDrawing()    
    
    ;   Save image        
    If SaveImage(#SCREEN_BUFFER,file$,#PB_ImagePlugin_PNG)=#False
      MessageRequester("Error", "Can't save background image.")
    EndIf
    
    ProcedureReturn file$   
    
  EndIf
EndProcedure

File$ = Main()
If File$
  Debug File$
  Mod1 = GetFileDate(File$, #PB_Date_Modified)
  Debug "  Modified: "+Mod1+" ("+FormatDate("%hh:%ii:%ss", Mod1)+")"
  
  Delay(1000)
  File$ = Main()
  If File$
    Debug File$
    Mod2 = GetFileDate(File$, #PB_Date_Modified)
    Debug "  Modified: "+Mod2+" ("+FormatDate("%hh:%ii:%ss", Mod2)+")"
    
    If Mod1 <> Mod2
      Debug #CRLF$+"Files are with different MODIFIED dates."
    EndIf    
  EndIf  
EndIf

Code: Select all

D:\Users\Thor\Documents\11111.png
  Modified: 1490486310 (23:58:30)
D:\Users\Thor\Documents\11111.png
  Modified: 1490486311 (23:58:31)

Files are with different MODIFIED dates.
ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley
Post Reply