Bug 31945 - File.SetLastWriteTime on network share throws System.IO.IOException: Invalid parameter
Summary: File.SetLastWriteTime on network share throws System.IO.IOException: Invalid ...
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: System ()
Version: 4.0.0
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2015-07-14 15:42 UTC by karol.bajkowski
Modified: 2015-07-15 01:57 UTC (History)
1 user (show)

Is this bug a regression?: ---
Last known good build:

Trace file. (193.80 KB, text/plain)
2015-07-14 15:42 UTC, karol.bajkowski

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report for Bug 31945 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

Description karol.bajkowski 2015-07-14 15:42:05 UTC
Created attachment 12024 [details]
Trace file.


I have problem with setting SetLastWriteTime.

First step is to mount network share i do fallowing commands:

sudo su
mkdir /media/test
sudo mount -t cifs //XXX.XXX.X.XXX/XX "/media/test" -o username=XXX,password="XXXXXXXX",file_mode=0777,dir_mode=0777

Next i created Program.cs file:

using System;
using System.IO;

namespace TestSetLastWriteTime
	class MainClass
		public static void Main (string[] args)
			try {
				var targetFullPath = "/media/test/test.txt";

				File.WriteAllText (targetFullPath, "");	// create empty file

				var lastWriteDt = DateTime.Now;
				Console.WriteLine ("File.SetLastWriteTime: " + lastWriteDt);
				File.SetLastWriteTime (targetFullPath, lastWriteDt);
				Console.WriteLine ("Program ended successfully.");
			} catch (Exception ex) {
				Console.WriteLine (ex);

Compile and run my program with fallowing commands:
/usr/lib/mono/4.5/mcs.exe Program.cs
mono Program.exe

My output is (i got exception):
File.SetLastWriteTime: 7/14/2015 9:27:32 PM
System.IO.IOException: Invalid parameter
  at System.IO.File.SetLastWriteTime (System.String path, DateTime lastWriteTime) [0x00000] in <filename unknown>:0 
  at TestSetLastWriteTime.MainClass.Main (System.String[] args) [0x00000] in <filename unknown>:0 

But should not throw any exceptions. Expected output:
File.SetLastWriteTime: 7/14/2015 9:27:32 PM
Program ended successfully.

My system informations:

mono --versionMono JIT compiler version 4.0.2 (Stable Wed Jun 24 10:04:37 UTC 2015)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
	TLS:           __thread
	SIGSEGV:       altstack
	Notifications: epoll
	Architecture:  amd64
	Disabled:      none
	Misc:          softdebug 
	LLVM:          supported, not enabled.
	GC:            sgen

uname -a
Linux kbpc 3.13.0-57-generic #95-Ubuntu SMP Fri Jun 19 09:28:15 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

I know that with my network share is everything ok because is use applications (not written by me) written in c++ that works OK. I do not know very well mono runtime and it's capability. Only one trace flag I found was:

mono --trace  Program.exe  > trace.txt

Trace txt in attachment. If there is some other way to trace or debug application I will do it (of course if it is not hard, because I'm not familiar with c, c++, and other relatively low level stuff).
Comment 1 karol.bajkowski 2015-07-15 01:57:38 UTC
I forgot submit compiler version:

/usr/lib/mono/4.5/mcs.exe --version
Mono C# compiler version