How to Open a file in Unity Android? - c#

I need to open a kmz file from the mobile app in order to see it in google earth, So i saved the kmz file in the StreamingAssets and i copy it to the persistentDataPath, Also the file is unable to open when i copy it to this folder.
Im calling it with this:
Application.OpenURL("file://"+Application.persistentDataPath + "/CR.kmz");
I already granted the file permissions.
I dont know how to open files from the storage with code. Help.

Related

Can't delete PDF files programmatically

I can't delete a pdf file from a shared drive (Windows mapped drive) from my c# Winform desktop program which runs on Windows 10 OS. The pdf file was created by Crystal Report in my c# program and when there is a revision, I need to delete the old pdf file and write the new one. I will get access denied error (HResult=0x80070005) when the program tries to delete the file. This only happens when the I try to delete it from a shared drive. If I generate the pdf file in the local drive (c:), and delete it from the local drive, then everything is find. I can manually delete the pdf file from File Explorer, but not from my c# program.
In addition, if the file is not a pdf file, then there is no problem to delete it from the shared drive.
It is weird that this only happens to pdf file or a file with .pdf extension. If I create a simple text file (test.txt) with C++ and save it in the shared drive, I can delete it without any problem. But when I create the same text file and name it as test.pdf, then I can't delete it.
HResult=0x80070005 seems only links to permission issue, but I strongly believe my case is NOT a permission issue because if the file is *.txt, then I can always delete it without any issues.
To rule out the possibility of the pdf file that may be still linked with the Crystal Report or opened by some programs, I copied the pdf file from the shared drive and save it in my local drive (c:) and wrote a simple c++ program to test if I can delete it, and it failed. Can't delete it. I can only delete it if the pdf file was created and saved in the local drive originally. And if the pdf file is copied from the shared drive to the local drive, then I can't delete it.
I would appreciate it if someone can shed some light on it.
I think (you/your app) don't Have Permission To Delete a File
Go to the folder that contains the PDF File.
Right-click on that folder and choose Properties.
Navigate to the Security tab.
Click on Edit, then click Add.
Under the Enter the object names to select box. Type
"Everyone"(without quotes) and click on Check names. Click OK.
A new window will open up with the Security tab. Under Permissions for
Everyone, check the Full control option. Select Apply and OK.
Ownership is already allowed for the folder.
Now you Can delete PDF files programmatically
Don't Have Permission To Delete a Folder
Thanks for trying to provide solutions for this problem. With a help from a friend, I finally found the root cause of the problem. It is the Norton antivirus that prevents me from deleting a certain types of files. .pdf is one of them. After I unchecked the .pdf from Norton, it works like a magic.
It is the antivirus program that prevents me from deleting .pdf file programmatically.

File Permission, after copy c#

I have a problem on my C# webapp
I need to copy a file from some network path
\\server01\sharedFolder\myfile.ext to inetpub/upload folder, and show the link to the user download the ext file.
When i use File.Copy (C#) the file lost all permissions and the browser user can't download the file. The iis keeps asking a windows credential to download the generated file.
I've tried to register .ext mime type and set file permission using FileSecurity.AddAccessRule without success.
how can i fix this ?

Need Help reading xml files from microsoft onedrive app folder

I am developing a windows 8 app in which i am trying to read xml files from Microsoft onedrive folder. The xml files get synced from onedrive to a particular folder. But when i an trying to read these synced xml files using StorgeFile.OpenAsync(FileAccess.Read) i get the following exception:
System.Unauthorized Exception occured in mscorlib.dll
HRESULT:0X80070005(E_ACCESSDENIED)
I am able to copy these synced files to some other location and also when i copy these files to some other location and paste it back to OneDrive folder i am able to read them
Check to see if the files are blocked. Right click on file and click on properties. If you see an Unblock button press it. If you have multiple files that are blocked, you can use the following PowerShell script:
Get-ChildItem c:\users\tech360\OneDrive - Tech360\Xml | Unblock-File

saving file in Assets folder in Windows 8 App

I am developing an App for Windows Store.
I have to save a recorded media as "file1.mp3" into the Assets folder without opening the save file prompt. I used the following code
StorageFile file = await Windows.ApplicationModel.Package.Current.InstalledLocation.CreateFileAsync(#"Assets\file1.mp3",Windows.Storage.CreationCollisionOption.ReplaceExisting);
However the system returns an "access denied" error. The file has to be saved in the Assets directory only and I do not want to use FileSavePicker. Please Help.
Thanks
Your package folder is read-only. Use your app data folders from Windows.Storage.ApplicationData.Current instead, wherein you'll find a LocalFolder and TemporaryFolder (also RoamingFolder but an mp3 would exceed the 100KB roaming limit). Then you can use either folder's CreateFileAsync.

How do I detect the what's the base folder for Google Drive?

I'd just need to detect the installation folder from a C# application so that I can open it. I guess that information is stored in a config file or registry setting.
Thanks a lot.

Categories

Resources