I am currently facing a problem, where I need to save a file (PDF) into downloads folder on iPhone (or in the best scenario prompt a download somehow) from Unity.
We can save data in Application.persistentDataPath, but that is, to my knowledge, inaccessible from the device itself.
Do you have any ideas, it will be something with the File class, but I do not know which path to put in there.
Related
I am learning C#, and have created an application with winforms that can play video files from my local hard drive. Here is my code for playing a file that is stored in the same directory as my exe file.
My question is - the actual file is still accessible to anyone that can access my exe folder, and therefore, can play the video file just by clicking on it. Is it possible to embed the video file in such a way that the actual video file remain inaccessible to someone I give my application to use? I mean he/she should only be able to use the exe file to access the application and then play the video using the application.
I have read this post here to get some idea: How to store a video file in exe file in c# and play it
However, this answer is also getting the physical file url, converting to bytes from resource and then using the url to play. Therefore, if I had to give my application to someone else I would still have to copy the physical file to a folder, and again it remains accessible for an open-by-click option.
I am a complete newbie on this, so advance thanks for helping me out.
{
string exepath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase);
string vdopath = System.IO.Path.Combine(exepath, "MyFolder\\SecondFolder\\VideoFile.mkv");
axWindowsMediaPlayer1.stretchToFit = true;
axWindowsMediaPlayer1.URL = vdopath;
}```
It's possible to add any file to a project and from the Properties set the Build Action to "Embedded Resource", then to read the file this SO answer - https://stackoverflow.com/a/3314213/4000335
I need to import a CSV file downloaded to a device into my Xamarin Forms application so that I can read the file contents, convert to Json and load into POCO objects and then send to SQLite database. My only question is how to select the file from the device file system for processing. I have looked at Gerald Versluis FilePicker Plugin for Xamarin and Windows. Is this my only choice for this process or is there something else available that I have not found?
Yes the the user needs to select the file from device storage, where ever that might be. The file picker plugin is what I decided to use as the plugin will let you select the file and read it into your app as a stream. Once you have the stream, you can pretty well do what ever you need.
I am writing a Windows Forms application in C#, and I want to copy files from a directory on my C:\ drive into the "Computer\SPH-D710\Phone\Music" directory on my Android phone. That music path I just copied and pasted from Windows Explorer to this post, but C# does not recognize it as a valid directory, probably because there is no "C:\" or the like.
What is a C# command that can write a file to an Android?
It appears your phone is connected as a MTP device (media transfer protocol). It is not as simple as a file system access (USB mass storage). Read these series of blogs on how to do it, its not a simple file copy.
https://learn.microsoft.com/en-us/archive/blogs/dimeby8/sending-mtp-commands-through-wpd-part-1-without-a-data-phase
https://learn.microsoft.com/en-us/archive/blogs/dimeby8/sending-mtp-commands-through-wpd-part-2-data-to-the-device
https://learn.microsoft.com/en-us/archive/blogs/dimeby8/sending-mtp-commands-through-wpd-part-3-data-from-device
Beware you will be diving into some unmanaged code for this.
The .NET libraries used to store files won't really care where they are saving the file. Your Android device is seen as a USB storage device (as long as USB storage is turned on from the phone's point of view!). I recommend that you put some of your C# code up so that we can potentially spot an error in the routine that you are running to actually save the file to the phone.
As a quick example - your C# code will likely want to look something like this:
string filePath = #"G:\Music\MySong.mp3";
System.IO.File.WriteAllBytes(filePath, mp3FileContent);
I have an application in c#.net in which I have embeded the SWF file in SWFObject from COM Object.
Now after installation, the original SWF file also available in the application root directory. So from that place(application root directory) anyone can access that file. But I want to restrict that file from being opened.
axShockwaveFlash1.Movie = Directory.GetCurrentDirectory() + "\\XYZ.swf";
I did something like this.
So how can I restrict that file in application root directory such that only from my application I can access it..??
You can embed the file into a dll or exe file and play it from there. this way it is not (as a seperate file) in the file system at all.
For details see How to embed and access resources by using Visual C#.
You could save the swf file binary data as static bytes in your code and statically load them and convert back to an swf file. The conversion might take a little while but it only occurs once as you open the program.
Edit:
But k3b's answer is better.
Permissions are based on users, not applications, so the short answer is you can't. However, you can build your own application-specific authentication pretty easily. Have your SWF require specific FlashVars to be set in order to move beyond frame 1. People can still decompile your SWF but this will at least stop most people. Another option is to try to store the data within you binary somehow and load the SWF using a byte-array, see this post for one attempt at that.
I'm building a video system, and have came across a problem of accessing a video held in a remote location. Now predicament is that I don't want to mess around with the zip file by extracting the data, this would take too long from a user perspective and would rather be able to open video file directly from within side the zip. My question is, is this possible? The ability to open a file is not something I've found within the DotNetZip library.
The only solution I've found is pointing VideoLAN at the zip file and playing it from there. However, doing this programmatically is something I'm massively struggling with, through the VideoLan DotNet for WinForm & WPF C# plugin and it's lack of examples. Just wondering is there any alternative means?
Why dont you use the VLC ActiveX Directly ,just import the AxVlc.dll to you're project ,than you can select the VLC Plugin from Toolbox in VS (VLC Plugin v2 prefered).
Than you can do something vlc.playlist.add("FileName",Null,""); than use vlc.playlist.play(); version's under 0.9.9 works with Loop ,new version's you should build the Loop Function by you're self.
What's the reason of compressing video files? They are already compressed, and far better than zip can do.