How can I load image into picture box from another computer? - c#

I need my picture box to load image from another computer. It means a different IP address. I have tried loading image from same computer and it works. But I need to load image from a separate server PC. The code below does not work.
pbFeature.Image = Image.FromFile(#"\192.168.232.100\C:\pic\a.png");

Network paths start with \\ not \. Assuming the file is shared correctly you just need pbFeature.Image = Image.FromFile(#"\\192.168.232.100\C:\pic\a.png");
Paste that same path into windows explorer and it should open the image if it is shared correctly.

share the file/folder to access by another computer. then you access file like below
var file= File.ReadAllText(#"\\server\path\filename.png");
then use the file where ever you want

Related

How to handle saved images locally vs on the server

I want to save some generated images.
The part which im confused about is how to handle the paths for saving files.
When running locally (in VS) the images can be saved in c:\images, but on the server id probably want to save them in root-of-webdir\images
do i need a configurable path in the web.config? how can i read the url path for the images in both cases?
You can use Server.MapPath to get the local directory name:
var folder = Server.MapPath("~/images");
This will usually give you 'c:\inetpub\wwwroot\application\images'.

Format a hyperlink to open the C drive

I am showing a list of hyperlinks on a web page that are intended to open windows explorer at the folder containing the file. The file paths are stored in a database and retrieved.
If the file path in question is showing in my C# code as \\\\myserver\\folder1\\somedocument.doc
I can set the href of the hyperlink to be: file://\\\\myserver\\folder1 and it works. Windows Explorer opens and shows the contents of folder1.
But, if the user who originally specified the file, selected one on his C:\ drive, I might have a path like this to deal with C:\\Somefile.txt
In this case I want to format the hyperlink so that it opens Windows Explorer and shows the contents of the C: drive. How can I do this?
file:///C:/ would work. But note, that this is only working in Internet Explorer. Neither Chrome, nor Firefox support such a behaviour. (Chrome and Firefox will list the drive's content in the browser instead of opening Windows-Explorer)
There are extensions for chrome, but i dont think, that this is what you are looking for.
It should work just the same as a network path. Have you tried file://c:\?
Other users will not be able to see that file of course, only the one that submitted it.
file:///c:/ should work for this
To open C:\ by default you can use: "explorer.exe /e,C:\"
Same syntax applies to fileshare: "explorer.exe /e,\myserver\folder1"

How to Copy Local Storage Image to Clipboard WinRT

I have an application, where user download images to the Local App Storage, it works like this because in order for the application to display content properly we dont want the user to have direct contact with the images and alter them.
Now we want the user to be able to copy the image to the clipboard or to make a copy in Pictures Library. The problem is that I'm getting this exception when trying to do it.
The code example is here:
http://imgur.com/qnltKTa
If I copy the image selecting it with the file picker, or getting it from Pictures Library my code works fine. But this happens when doing it from the Local Storage Folder.
Your code has mistake. Remove "\\" from this line
StorageFile storageFile = await folder.GetFileAsync("Circulo 2_Atomo.png")

How to get path to file in winforms application

How can I get the path of a file on my computer or on the local area network.
I would to show a window that allows me to browse the file system when I click a button, and I want to select a file and get the path to the file. How can I do this?
P.S. I'm not looking to upload the file; I just want to get the path.
The web application is running on the server, and you don't have access to the client file system at all. Can you imagine how much of a vulnerability that would be? I know I don't want the sites I visit inspecting my file system...
EDIT: Question is for a WinForms application
For a WinForms application, you can use the OpenFileDialog, and extract the path with something like this:
If you're looking for the file path:
string path = OpenFileDialog1.FileName; //output = c:\folder\file.txt
If you're looking for the directory path:
string path = Path.GetDirectoryName(OpenFileDialog1.FileName); //output = c:\folder
In general, the System.IO.Path class has a lot of useful features for retrieving and manipulating path information.
To do this in VB.NET use the FolderBrowserDialog.
Due to security restrictions browsers include for user safety, you can't manipulate the client file system directly. You can only use to let them pick a file, and even then it only sends the filename, not the whole path.
The FileSystem API in HTML5 allows for file manipulation, but only within a sandbox for your site specifically, not browsing across the network or other files on the client system.
Instead, provide your users easy steps on how they should use My Computer (or whatever equivalent on other OS's) to navigate to the file and copy & paste the path into a simple text input box.
Have you taken a look at the Path class from System.IO ?

accessing network path and copy file to the system = c#

i want to create a small c# application. there is a text box and a button in form. if anyone enter a network path for a file and press the button, then the application must copy that file to a folder within that system. How can i do this.?
How to access a network path and how can i copy the file in that path to the system??
You can use the OpenFileDilog class in .net to browse through the files.
Also you can visit these links for Copy and other functionalities.
http://msdn.microsoft.com/en-us/library/cc148994.aspx
http://msdn.microsoft.com/en-us/library/system.io.file.copy(VS.71).aspx
Net work paths are accessed by there full UNC ie \Server\Share\drive\file. As long as you have credentials to access them. You can use system.io.file.copy to move the files.

Categories

Resources