That will be super idiot question, but I don't usually write in Visual studio and C#...
The question is:
how do i save files while making the gui applications in "windows form application" ? I mean, how to save it and send it to someone and he will be able to open it and the code & designer thing will be visible?
Normally, when did the console applications it was no problem - just saving the .cs... But now - when i save it, i get milion of files, and none of them shows me the designer thing, but only the code...?
All you need to do is zip up the source files with the .sln. He unzips on his side, double clicks the .sln file and all done.
In the above image you can see, a solution file along with the projects in their respective folders. You just zip up the folders with the .sln (solution file) and all done.
Related
I have students in high school who have created some programs using Visual Studio C#. They created some games and would like to now upload them to the web. I am pretty new to Visual Studio C#. I thought after a program was "built" that you could go into the bin/debug folder and get the exe file for the program and be able to play the game without having to have Visual Studio on the actual computer you are playing it on. It works with some of their games but some of them, there are graphical files that are missing in the exe file if all the other files aren't stored in the same place. How can I get a clean exe of their game? Can that exe be loaded up onto a web server so they can play it from there or at least download it from there?
Microsoft wrote a guide on how to do exactly this. It's on their MSDN website, which is sort of like the developer back-bone for a lot of Microsoft software and documentation.
Old guide: Adding and Editing Resources (Visual C#)
Newer guide: How to: Add or Remove Resources
The gist is that the program needs to know where the files are, relative to the location of the compiled binary (in this case, an .EXE); There's several different ways to do this, depending on your level of expertise. I would suggest that you take a look at the guides above to start that journey.
there's a few ways of doing this. (Also, make sure you're creating a 'release' build when you compile).
You can include resources in your game by creating a resources file. This is something I usually do only on winforms applications etc.
If you have on-disk files you need to distribute those on-disk files along side your game. You could do this by zipping up your game.exe and the /files/images.img folder (or what ever your resources content folder is named).
If you're feeling adventurous you could create a 'deployment project' which is a project that allows you to create an installer file. This is a bit more work however you will have fine grained control over what files go where etc.
Good luck!
EXE files generally aren't self contained for video games with many resources, just add resources in an external folder and make sure the paths to the resources in their games are not absolute but relative in the local directory.
So for example:
get rid of paths like C:/Users/Bob/Desktop/Game/Images/player.png and replace with /Images/Player.png.
Also, an EXE generally doesn't run client side on webpages, it is possible but difficult. Things such as Flash are made for this sort of issue. I'd say make the webpage a place where they can download their games. Github has a nice way to do free websites called gh-pages. OFC, you could host one yourself but that would require a lot of setup work.
Like Monza said, you can zip up the files for download. Or, you could create an installer if you wanted to be really ambitious.
I thought after a program was "built" that you could go into the bin/debug folder and get the exe file for the program and be able to play the game without having to have Visual Studio on the actual computer you are playing it on.
That is correct, given that the other machine has the necessary .NET framework version installed AND any other resources like .dll files and config files are also present. When the application is ready for release, you can set the Build options in the project properties to Release, and then when you build all the files needed for distribution will be in the bin\Release folder.
It works with some of their games but some of them, there are graphical files that are missing in the exe file if all the other files aren't stored in the same place.
This may depend on how the application was written. If resources like pictures are embedded in the assembly then those files will not be needed to run on another machine. If the application is using hard coded paths for the image resources in the source code, then the application will likely break if the necessary files aren't present when the .exe is executed.
Can that exe be loaded up onto a web server so they can play it from there or at least download it from there?
Yes - you could upload the .exe to a file server to make available for a download, but you would not be able to run it within a browser over the web. I would recommend zipping up the .exe and other files needed and hosting the .zip file on the web server for download; browsers may give a warning or block downloading an .exe .
Hope this explains it a little bit for you.
In my C# application i have a help button. When it's pressed I would like for the application to open up a PDF file in the systems default PDF reader, something I can do with a command like Process.Start("pathToPDF").
The problem is that I would like to include the PDF as a resource instead of calling an external file. I do not wish to copy the PDF to the users computer and do not want to host it online or on a NAS.
Right click on your project in the Solution Explorer, then add existing file and choose your pdf (if you cannot find it, make sure you are showing all files and not just .cs files etc.).
Click on the newly added item once in the solution explorer and in the properties window, you set Copy to Output Directory to Copy Always or Copy if newer.
Now you can open the pdf file as expected using Process.Start(filename.pdf);
The only Secure way to show a PDF without providing a file is to include your own Viewer Component (Ex. http://www.o2sol.com/pdfview4net/overview.htm)
Some components allow to load a PDF from Memory (as in a embedded Resource) directly into your Viewer Component, another way would be to create an encrypted binary file to ship with your application and encrypt/load when necessary.
As soon you want to show the PDF in an external viewer ,be aware that the User will have the ability to save the PDF anyway.
Maybe you can explain your reasons to not want to include the file, so we can suggest other solutions to you?
Update:
As noted in your comment, the goal is to have a clean installation.
It would be possible to embed the File as a resource, but then you would
have the problem that if you extract the file temporarily to display it, you can't really control the clean-up of that file, because it's locked by the PDF Reader Application.
So you would end up with the PDF File anyway ;)
What you can do to keep your Application Folder cleaner, is to not install the PDF under that Application Folder but under the "Common Documents" Directory.
For Example: Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments), "MySoftware", "Help.pdf")
Which normally targets: C:\Users\Public\Documents\MySoftware\Help.pdf
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.
I am new to SO and also to the C# language. I browsed for a bit and was not able to find anything relating to this subject. I program in other languages, mainly C and C++. When I want to show someone my code I show them the .c or .cpp files and any header files I have created.
However, if I want to show the source code to a program in C# what do I use?
It is especially confusing when I create a new WindowsFormApplicaiton
Technically all you need is the .cs files, but to make it easy on the person receiving this (and assuming you are using Visual Studio) just take the entire Visual Studio project directory (should include a .sln file, one or more .csproj files, all the .cs files, and any other assets) and zip/rar it.
The user on the receiving end can unzip the whole structure and double-click the .sln file, and they will get the same view in Visual Studio that you had.
A little more detail:
Forms are still just c# (.cs text) files.
The .csproj is an XML file that contains pointers to all your .cs files, as well as some project metadata.
The .sln file is an XML file that contains pointers to all your .csproj files, as well as some metadata about source control, project relationships, etc.
When you create a Winforms application, you get two .cs files: Program.cs and Form1.cs. When you are looking at the form, you can right-click on it and choose View Code. This is called a "code behind", and is where the implementation of the form lives.
You can use notepad (open the .cs file) or visual studio. If you don't have a pro copy you can use one of the express editions of visual studio. When in VS you can right click on the form and select View Code. I hope my response is on track with your question!
a strange behavior happens when install the application and then run the exe file.
first let me explain my steps:
1) i added HelpProvidor and i set HelpNameSpace property to the chm file path.
2) in the form properties i set HelpNavigator on helpProvidor property to : KeywordIndex
and HelpString on HelpProvidor to Use ASGATech Quran Sound Downloder Help
3) i created an installation pkg. and it runs successfuly.
My problem is when i debug the application and presses on "?" (which is the help button) it displays the chm file.
but when i run the sortcut on the desktop which has been created from the installation package it doesn't.
why is that the HelpNamespce is the same. and the exe which is in the Application folder is that same so why is that.
the exe file is the same and also when i created a new item in start -> program menu the exe file that created runs the chm file but the shortcut doesn't.
i put the chm with the application folder which throws the application folder on:
c:\program Files\Manufacturer\ProductName
and it put the file on this path successfuly so why he can't see it.
EDIT:
i found that the problem is when i uninstall the application it keeps the product folder
it only removes the icon ans chm and so when u reinstall the application he dont feel the new state (that he has chm file)
now how could i remove the product file from programFiles.
Are you sure the exe file is the same?
It seems that either the help file is not found by your application or that the current security settings of IE prevent it from being loaded.
Use a tool like Procmon to see where your application is looking for the help file.
If it is not found make sure that it is included within your installer package.
If it is found make sure that it is on the local disc and that the default security settings for your local machine have not been changed within IE.