Is there any way to send a picture WITH the code in Windows Forms? - windows-forms-designer

I designed a windows forms, in which to insert a picture, I placed a PictureBox. To insert the picture in the pictureBox, I have to give the path of the image file in the code. But if I run this code in another computer, it does not work; since the path of the picture is saved in my computer.
So is there any way to export the picture along with the code?? Like we do in Android Studio, where we save the files to be used in the code project.

I think you need to place your pictures in Debug folder of your project solution. If you are using Image.FromFile() method so you can just write the name (relative path) of your pictures with extention. Let suppose I have a picture named dice1.png residing in my solution's Debug folder (C:\mySolutionName\myProjectName\bin\Debug) so I can getdice1.png in the program by writing follwing code,
Image dicePicture = Image.FromFile("dice1.png")
pictureBox1.Image = dicePicture;
Hope this helps!

Related

ASP.net; automatically generated .js classes cannot be altered in their base files

I am working on something that totally baffles me. In my ASP.net project, I have this file:
It goes by the name of base.js and is a mere 4214 lines long.
If I hit debug in my app, then suddenly, a new folder appears in within my solution that goes by the name of "script documents", and looks like this:
At the very bottom , you see a little file called: base.js.
This file is an exact copy of my base.js from "earlier".
Now, I can even make stop points inside this automatically generated file and they work!
But if I now were to make changes to the base.js file (the OG one), none of the changes are transmitted to the auto generated file.
I guess this has something to do with the version code, but I couldnt really figure out how that works.
How can I alter these auto generated script files?
Thank you!

How can I get the full path to the file I saved my code in when it is currently executing and writing out HTML for me?

I tried to make my title as direct as humanly possible.
I wrote some code, saved it in a file. I want the name of that file, and the disk path to it, at the moment it runs. This is for a website, and I have access to HttpContext.
I wrote some code in a Razor file. I put that file on my IIS website, and it got executed by some convoluted hierarchy steps with partials and the like. I want to write some code that spits out the path to that file.
I don't want to hard-code the filename and its current path in my code. I want to copy the magic piece of code I'm asking for here onto lots of other Razor pages, so each time I can spit out a comment in some script or style tag somewhere so that other developers can track down my mistakes amazing work.
I don't want to know how the end-user's browser got to my file. I'd use Server.MapPath or Request.ServerVariables["SCRIPT_NAME"] if I wanted that.
I don't want to know merely what directory my website app is running in. I'd use HttpContext.Current.Request.PhysicalPath for that.
Does anybody know how to do this?

How to change working directory via extension in Adobe brackets

Given a file or path - I can use FileUtils (or similar) to work with files. I'd like to be able to alter the current working directory in my extension.
I see in node.js there is process.chdir(directory) but I am unable to access that object.
Is there any other way to change the current working directory.
I am trying to create a simple plugin that when you open the file dialog, the directory your file listing is the same as the currently opened file. The simple implementation being:
MainViewManager.on("currentFileChange", function (e, newFile) {
process.chdir(newFile.parentPath); // This is my FAIL
});
Brackets, like many GUI apps, doesn't use the current working directory very much once it's up and running. So there is probably a different way to accomplish what you're looking for.
When you say...
when you open the file dialog, the directory your file listing is the same as the currently opened file.
...do you mean you want the file tree on the left side of the window to change? If so, try the ProjectManager.openProject() API.
...or do you mean you want to open a file-picker dialog box (like what you see when you choose File > Open in the menu)? If so, you can use FileSystem.showOpenDialog() - the 4th argument is the directory to show when the dialog is first opened.

Why my image source is not working for my current local machine but it's working for the web sources?

I have a div and I want to show images as innerhtml using the back end C# code. So that I can generate them as I want them to. In here for innerhtml everything is running fine but the images. While I am giving it a path from my current localhost the images are not showing but while I am putting an web url its working why?
Even if I tested taking the suggestion from the visualstudio like I put a static image in front end and took its path but its still not working. I user the server.mappath(test) this function too.
test = "App_Data/images/37id4.jpg";
divfifth.InnerHtml ="<img src='"+test+"' />";
This says the path is not found here is my code given.
if anyone can suggest me to generate these in better way please suggest.
Hello #Borshon Aeolus Saydur , Its a nice question. Try to give add path like "~/images/.." format. instead of "Images/..".
i have solved it by moving my image folder one layer up.although i dont know what was the wrong in previous layer.but its now working after moving it to its upper layer..

Windows form application - Icon image location?

I think this should be a relatively easy one to answer, I hope, but is proving to be a bit of a stress!
I have used an Icon on an old application developed some years ago and I would now like to use the icon for a current project.. however..
I added the icon using the upload/import icon-image in the properties window, and did not add it in the project resources file, nor specify its location anywhere in my code, using only the icon tool in the properties window.
Now wanting to find the icon image file to use again, I cannot find it anywhere! I have trawled through all the project files looking for the image file or a ref to its location, but have found nothing; except for:
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
When running the application the icon is still clearly visible in the applications taskbar tile.
Does anyone know where the icon file is stored / how I can retrieve it?
Thank you in advance.
It is stored in "{Your_project_name}.{Form_name}.resources" file. Search inside the "obj" folder which is in your project folder.
Now open the command prompt of Visual Studio. We will convert this ".resources" file into a ".resx" file. We use "resgen" command here.
resgen foo.resources bar.resx
The .resx can then be added to a C# project. You can find your icon file there.

Resources