Bug 55520 - File.Move of filenames with special characters in filename does not work
Summary: File.Move of filenames with special characters in filename does not work
Status: CONFIRMED
Alias: None
Product: iOS
Classification: Xamarin
Component: Mono runtime / AOT compiler (show other bugs)
Version: XI 10.8 (d15-1)
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: Future Cycle (TBD)
Assignee: Zoltan Varga
URL:
Depends on:
Blocks:
 
Reported: 2017-04-24 14:33 UTC by gaoyuan_chen
Modified: 2017-09-22 20:26 UTC (History)
7 users (show)

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


Attachments

Description gaoyuan_chen 2017-04-24 14:33:39 UTC
Using System.IO's File.Move of filenames with special characters in other languages causes file to be hidden.  For example, changing a filename from test.m4a to "Ö.m4a" causes the file to "disappear" in the file system.   Issue in other languages other than Japanese also exists. Trying to read the file via NSUrl or AVAudioplayer does not work.  Downloading the app container and inspecting the container contents does not show the file exists.

Using System.IO's Directory.GetFiles(...) will return the file as an existing file.  Attached is a sample app that reproduces the issue.  I was unable to reproduce this issue using a native iOS app written in Objective-C.



=== Xamarin Studio Enterprise ===

Version 6.3 (build 863)
Installation UUID: 62529d90-ec50-44f6-b4ba-33ac477e80fd
Runtime:
	Mono 4.8.1 (mono-4.8.0-branch/22a39d7) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 408010000

=== NuGet ===

Version: 3.5.0.0

=== Xamarin.Profiler ===

Version: 1.4.0
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Apple Developer Tools ===

Xcode 8.3.2 (12175)
Build 8E2002

=== Xamarin.Mac ===

Version: 3.2.0.175 (Visual Studio Enterprise)

=== Xamarin Inspector ===

Version: 1.2.2
Hash: b71b035
Branch: d15-1
Build date: Fri, 21 Apr 2017 17:57:12 GMT

=== Xamarin.Android ===

Version: 7.2.0.7 (Visual Studio Enterprise)
Android SDK: /Users/cheng/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		6.0 (API level 23)

SDK Tools Version: 25.1.2
SDK Platform Tools Version: 24.0.0
SDK Build Tools Version: 23.0.2

Java SDK: /usr
java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Xamarin.iOS ===

Version: 10.8.0.175 (Visual Studio Enterprise)
Hash: a04678c2
Branch: d15-1
Build date: 2017-03-28 14:05:38-0400

=== Build Information ===

Release ID: 603000863
Git revision: a2163670efe259c85cd8f335d95b175068fbbe2a
Build date: 2017-04-03 14:33:15-04
Xamarin addins: 2045d688ea1420e0381b473360ca62a763eb7d04
Build lane: monodevelop-lion-d15-1

=== Operating System ===

Mac OS X 10.12.4
Darwin hqchengaoymacbook.ms.starkey.com 16.5.0 Darwin Kernel Version 16.5.0
    Fri Mar  3 16:52:33 PST 2017
    root:xnu-3789.51.2~3/RELEASE_X86_64 x86_64
Comment 1 Alex Soto [MSFT] 2017-04-24 15:57:18 UTC
Hello, thanks for contacting us!

> Attached is a sample app that reproduces the issue

It seems the attachment did not make it, would you be able to provide said test case to us?
Comment 2 gaoyuan_chen 2017-04-24 16:16:57 UTC
Hi, thanks for replying. It seems like I could not attach again so I have copied the viewcontroller.cs code in here.

using AVFoundation;
using System;
using System.IO;
using UIKit;
using Foundation;
namespace XamarinAVAudioTest.iOS
{
	public partial class ViewController : UIViewController
	{
		AVAudioPlayer _libraryAudioPlayer;
		int count = 1;

		public ViewController(IntPtr handle) : base(handle)
		{
		}

		public override void ViewDidLoad()
		{
			base.ViewDidLoad();

			// Perform any additional setup after loading the view, typically from a nib.
			Button.AccessibilityIdentifier = "myButton";
			Button.TouchUpInside += delegate
			{
				var title = string.Format("{0} clicks!", count++);
				Button.SetTitle(title, UIControlState.Normal);
			};

			//testButton.TouchUpInside += TestButton_TouchUpInside;
		}

		partial void buttonClick(Foundation.NSObject sender)
		{
			//TODO: change name and play audio here;
			string filename = "test";
			var sourcePath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
			string source = Path.Combine(sourcePath, filename) + ".m4a";
			//1) change the filename into "Ö.m4a"
			string changeName = "Ö";
			var destinationPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
			string destination = Path.Combine(destinationPath, changeName) + ".m4a";
			//2) Move "Ö.m4a" into other directory
			if (File.Exists (destination)) {
				File.Delete (destination);
			}

			File.Move(source, destination);
			//3) Transform string path into url
			NSUrl url = NSUrl.FromString(destination);
			//4) Play audio w/ AVAudio
			_libraryAudioPlayer = AVAudioPlayer.FromUrl(url);
			_libraryAudioPlayer.Play();
		}

		public override void DidReceiveMemoryWarning()
		{
			base.DidReceiveMemoryWarning();
			// Release any cached data, images, etc that aren't in use.		
		}

		//void TestButton_TouchUpInside(object sender, EventArgs e)
		//{
		//	//TODO: 
		//}
	}
}
Comment 3 gaoyuan_chen 2017-04-25 13:26:47 UTC
Also, this bug only exists in iOS 10.3 and worked as expected back in version 10.2
Comment 4 Rolf Bjarne Kvinge [MSFT] 2017-04-25 13:54:42 UTC
This might be related to Apple changing the file system to APFS: https://mjtsai.com/blog/2017/03/24/apfss-bag-of-bytes-filenames/
Comment 5 gaoyuan_chen 2017-04-25 14:38:11 UTC
The blog post recommends using NSFileManager.  Is there an ETA on when File.Move will be updated to be compatible with APFS+?
Comment 6 gaoyuan_chen 2017-04-25 17:31:37 UTC
Thanks for your help! I've solved that problem by replacing File.Move to NSFileManager move methods and it works well!
Comment 7 Alex Soto [MSFT] 2017-04-26 15:51:26 UTC
@Kumpera and @Marek FYI, also Apple could turn this on for macOS at some point and cause more issues in the long run.
Comment 8 Manuel de la Peña 2017-06-05 16:06:21 UTC
Adding Ludovic in the loop regarding this.
Comment 9 Vincent Dondain [MSFT] 2017-07-16 23:13:07 UTC
Marking this bug as CONFIRMED. The milestone is set to TBD which is ok since there's a workaround (NSFileManager).

Guess it's fair to keep this bug around until File.Move is working on 10.13.

Note You need to log in before you can comment on or make changes to this bug.