Can't set CreationTime on File

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Can't set CreationTime on File

JLee
I think, the following code worked in the past but now I get an error when setting the timestamps (Invalide Parameter).

FileInfo fi = new FileInfo(file);
fi.Attributes = FileAttributes.Normal; <-works
fi.CreationTime = timeCreate;  <-fail
fi.LastWriteTime = timeLastWrite; <-fail
fi.LastAccessTime = timeLastWrite; <-fail
fi = null;

My mono-version hasn't changed (still 4.2.7) for month, now.
Has google something changed in Android that prevents changing filetimes?


regards
Lee
Reply | Threaded
Open this post in threaded view
|

Re: Can't set CreationTime on File

JLee
timeCreate, timeLastWrite, timeLastWrite are all DateTime-Types.
Reply | Threaded
Open this post in threaded view
|

Re: Can't set CreationTime on File

nodoid
In reply to this post by JLee
Hi,

> I think, the following code worked in the past but now I get an error when
> setting the timestamps (Invalide Parameter).
>
> FileInfo fi = new FileInfo(file);
> fi.Attributes = FileAttributes.Normal; <-works
> fi.CreationTime = timeCreate;  <-fail
> fi.LastWriteTime = timeLastWrite; <-fail
> fi.LastAccessTime = timeLastWrite; <-fail
> fi = null;
>
> My mono-version hasn't changed (still 4.2.7) for month, now.
> Has google something changed in Android that prevents changing filetimes?

Can you create a small test case showing the problem? If you've not
changed anything, the code should still work.

4.2.7 of Xamarin.Android is really old (the alpha version is on 4.8.0
with the stable being 4.6.8) and all of them IIRC use the mono-3 branch now.

You might want to try

fi.CreationTime = timeCreate.TimeOfDay;

as well

Paul
--
"Voila! In view humble vaudevillian veteran, cast vicariously as both
victim and villain by the vicissitudes of fate. This visage, no mere
veneer of vanity, is a vestige of the “vox populi” now vacant, vanished.
However, this valorous visitation of a bygone vexation stands vivified,
and has vowed to vanquish these venal and virulent vermin, van guarding
vice and vouchsafing the violently vicious and voracious violation of
volition.
The only verdict is vengeance; a vendetta, held as a votive not in vain,
for the value and veracity of such shall one day vindicate the vigilant
and the virtuous.
Verily this vichyssoise of verbiage veers most verbose, so let me simply
add that it’s my very good honour to meet you and you may call me V.."

_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid
Reply | Threaded
Open this post in threaded view
|

Re: Can't set CreationTime on File

Jonathan Pryor-2
On Jul 23, 2013, at 7:39 AM, Paul Johnson <[hidden email]> wrote:
> 4.2.7 of Xamarin.Android is really old (the alpha version is on 4.8.0 with the stable being 4.6.8) and all of them IIRC use the mono-3 branch now.

This is not entirely correct. Mono for Android 4.2.x, Xamarin.Android 4.4.x, and Xamarin.Android 4.6.x are all based on Mono 2.10.

Xamarin.Android 4.8.x will be the first release based on Mono 3.0.

 - Jon

_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid
Reply | Threaded
Open this post in threaded view
|

Re: Can't set CreationTime on File

Jonathan Pryor-2
In reply to this post by JLee
On Jul 23, 2013, at 7:08 AM, JLee <[hidden email]> wrote:
> I think, the following code worked in the past but now I get an error when
> setting the timestamps (Invalide Parameter).
>
> FileInfo fi = new FileInfo(file);

What is `file` (the full path). Do you have permission to change it? Have the filesystem permissions changed since you last ran the app? What device is this on?

 - Jon

_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid
Reply | Threaded
Open this post in threaded view
|

Re: Can't set CreationTime on File

nodoid
In reply to this post by Jonathan Pryor-2
Hi,

>> 4.2.7 of Xamarin.Android is really old (the alpha version is on 4.8.0 with the stable being 4.6.8) and all of them IIRC use the mono-3 branch now.
>
> This is not entirely correct. Mono for Android 4.2.x, Xamarin.Android 4.4.x, and Xamarin.Android 4.6.x are all based on Mono 2.10.
>
> Xamarin.Android 4.8.x will be the first release based on Mono 3.0.

Thanks for the correction :)

Paul


--
"Voila! In view humble vaudevillian veteran, cast vicariously as both
victim and villain by the vicissitudes of fate. This visage, no mere
veneer of vanity, is a vestige of the “vox populi” now vacant, vanished.
However, this valorous visitation of a bygone vexation stands vivified,
and has vowed to vanquish these venal and virulent vermin, van guarding
vice and vouchsafing the violently vicious and voracious violation of
volition.
The only verdict is vengeance; a vendetta, held as a votive not in vain,
for the value and veracity of such shall one day vindicate the vigilant
and the virtuous.
Verily this vichyssoise of verbiage veers most verbose, so let me simply
add that it’s my very good honour to meet you and you may call me V.."

_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid
Reply | Threaded
Open this post in threaded view
|

Re: Can't set CreationTime on File

JLee
In reply to this post by Jonathan Pryor-2
file = fullpath
the file is in my app-folder under external-storage.
the original file comes from a windows-system an is unzipped in the folder.
today i testet with a file i created by myself direct on the device (File.Create) , to check, if it is permission-related. i get "invalide paramter", also.

to make sure i have write permission on the file i added "fi.Attributes = FileAttributes.Normal";
was that wrong?

Devices are S3 and Note 2.

Reply | Threaded
Open this post in threaded view
|

Re: Can't set CreationTime on File

Samus Arin
In reply to this post by JLee

Could be a security issue (try chmod ing the file).

On Jul 23, 2013 7:08 AM, "JLee" <[hidden email]> wrote:
I think, the following code worked in the past but now I get an error when
setting the timestamps (Invalide Parameter).

FileInfo fi = new FileInfo(file);
fi.Attributes = FileAttributes.Normal; <-works
fi.CreationTime = timeCreate;  <-fail
fi.LastWriteTime = timeLastWrite; <-fail
fi.LastAccessTime = timeLastWrite; <-fail
fi = null;

My mono-version hasn't changed (still 4.2.7) for month, now.
Has google something changed in Android that prevents changing filetimes?


regards
Lee



--
View this message in context: http://mono-for-android.1047100.n5.nabble.com/Can-t-set-CreationTime-on-File-tp5713422.html
Sent from the Mono for Android mailing list archive at Nabble.com.
_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid

_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid
Reply | Threaded
Open this post in threaded view
|

Re: Can't set CreationTime on File

najak3d
I'm having the exact same issue with the latest Xamarin build 4.2.2.

I was doing this same thing under "MyDocuments" just fine.   But then I swapped it out to ExternalStorage location, and everything works fine *except* for code that tries to modify the "CreationTime" (for a Zip inflate function).  To fix it, for now, I just removed the offending lines of code; but now the function is defective, since the file dates *should* be set to whatever they were set inside the archive (to preserve their actual time stamps).

If I switch my path back to "MyDocs" it works fine; but for External Storage, I'm unable to set File dates.
Reply | Threaded
Open this post in threaded view
|

Re: Can't set CreationTime on File

sarahzohar88
This post has NOT been accepted by the mailing list yet.
In reply to this post by JLee
I want to find exact this type of forum thread so thanks for it