Xamarin in Visual Studio File import to Solution - c#

I Try to Open a file within Xamarin.
I followed this tutorial:
https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/files/#Loading_and_Saving_Files
The File that i wand to open seems to not exist.
It opens the path "/data/user/0/SQL2.Android/files"
I tried all different properties on the file.
I don't know if the file I want to open is in the Solution. It should be.

Related

Open pdf file dynamically from toolstripmenu c# winform

i'm trying to open a pdf file from my winform application, while the pdf file is in the directory of the application. I want to pack this app latter so I can open them dynamically even if the app is installed in another machine. I'm using Process.Start(".\file.extension") but I'm getting the error: The system cannot find the file specified. I heard that I need to send it in System32 folder but when I pack it I have no idea how to send it there. Hope you understood and can come with a solution for this problem. Thanks in advance.
If the pdf file is inside the project itself, You can simply do this:
Your PDF File as seen from the solution explorer > Right Click > Properties
Copy to Output Directory > Copy Always
After this, each time you build your project or when you deploy it, The PDF file will always be included in the project output folder.
Try this...
string commandexec = string.format("{0}\{1}",AppDomain.CurrentDomain.BaseDirectory,filename);
Process.Start(commandexec);

Moved Visual Studio Project - Directory Not Found Exception

I have recently copied an entire Visual Studio project (folder containing all files and subfolders) from one machine to another.
I've then opened the project .sln file, and hit debug. The first error that i get it that it can't find Form1 (the very first Windows Form in my project). It gives me the option to select the file manually, but if i navigate to the Form1 file it tells me that the:
Source file is different from when the module was built. Would you like the debugger to use it anyway?
If i do this, the next thing i get is a DirectoryNotFoundException whereby it's looking at this file path:
Could not find a part of the path 'O:\TestDaws\CSDB'.
Now this file path did exist where i was running this program from previously (at work). Now i'm trying to run it from home, it does not. But i cannot find ANYWHERE that refers to the O: drive in my code. Tried searching and it finds nothing.
The only answers i can find seem related to Source Control. And i have no source control. Also seen people recommending deleting the .suo file. I'e tried that and that also has no affect.
The file path it's looking for must be in some meta data or settings file somewhere that Visual Studio creates, and i can't find. Any ideas please?

How can I publish a Windows Form app to include a csv file?

I'm creating a Windows Form application that is going to be used as a sign in system at my college. I was given a .csv file that includes student id numbers, names, teachers, and current courses. I have the app created and it works when I use it on my computer. However, when I publish the application and install it on a different computer, the streamReader that I use to access the .csv file is not able to use the .csv file because it's nowhere in the published application. I have tried adding the file to the root directory of the project, but I can't find out how to access it from there. I've read a few forums that talk about adding the file as a "resource," but I don't know enough about that to make it work for what I'm doing. Any assistance would be appreciated. Thanks!
In visual studio, add the file to your project (Add Existing after right click on the project). You'll need to add a build action as well, to tell the IDE to copy the file to the output directory. To do that, right click on the file you added, go to Properties, and look for BuildAction.

Modify c# Windows Forms control library

I have a c# Windows Forms control library, but there is no sln file with it.
I would like to modify this project, so I think I need an sln file to open it and create an other dll.
I tried a solution, but it did not work.
I create a new c# Windows Forms control library, I named it as the original library name.
I renamed the UserControl1.cs as the original mainfile name.
I bult it, it has worked, yet.
After that I copied all of the .cs files from the original library to the new library.
Of course overwrite the new files with the original files.
I tried to build it again, but I got an error message: "dll does not contain any usercontrol types"
The original folder contains a __csproj.user file, but my new project does not contain it.
What did I wrong? How can I modify the original c# Windows Forms control library oe how can I create an sln file for it?
If you don't have .sln file, that's fine visual studio will create it for you when you open a .csproj file and try to save the project.
All you have to do is open the .csproj file in visual studio and save it.

How do you output a resources file from C# application?

I am using Visual C# 2010 Express. I would like to put .dotx or Word Template files into the Resources folder of my application and when it is installed, output the files to a different directory preferably C://Myfolder/. I couldn't find anything about it here. Are there any ways to solve this?
Why would you want this as a resource? Why not bundle it as part of the installer package which can work out where to put the file when your application is installed?
Click on Resources (in "Properties"), and then on the arrow next to "strings" and choose "files".
Then drag the file in and name it. then use:
Properties.Resources.fileName;
which will be a byte[], and save it using:
File.WriteAllBytes(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + #"\filename", Properties.Resources.fileName);

Categories