I am creating a Windows Application using C# which access a mapped drive (Z:\ is a mapped drive for a shared network folder) to grab the files inside the folder but return an exception error :
The system cannot find the path specified.
I have two different functions that will access this mapped drive. One function will display the image file found inside the shared drive to the windows application. Codes as below :
Display image file :
if (System.IO.File.Exists(photoPath))
{
pbImg1.ImageLocation = photoPath;
}
else
{
pbImg1.Image = eMapViewer.Properties.Resources.TempImage;
}
When double click on the image file on the windows application, the codes will call for another function to open the actual files on map drive :
Double click to open image file :
if (System.IO.File.Exists(photoPath))
{
Process.Start(#photoPath);
}
The first function (Display Image File) works without any issues. The image file is able to be displayed on the windows application. However, the second function (Double click to open actual image file) returns the exception error. I can confirm that both functions use the same photoPath of :
\\AOI\Backup\Mapping\picture.bmp
I was referring to this thread I found but cannot find the solution. Process.Start and "The system cannot find the path specified"
Can someone help on this?
Related
I tried
Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
they both return same results
This image in the question representing a Windows File Explorer view of the Desktop root item is a virtual view constructed by the explorer.
As I know it has no physical existence on the drive and its content varies with the Windows version from 95 to 10.
The Desktop folder in the User folder on the drive only contains links and files shown on the screen (the desktop).
Perhaps there is a WinAPI to get such list but I don't know.
Perhaps it is somewhere in the registry.
Perhaps you can found something with Explorer-like implementations.
How to create an Explorer-like folder browser control?
https://www.c-sharpcorner.com/UploadFile/17e8f6/windows-explorer-in-C-Sharp-net/
https://www.codeproject.com/Articles/15059/C-File-Browser
https://learn.microsoft.com/en-us/windows/win32/shell/folder-info
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
Here is my code:
Uri u = new Uri(#"C:\roomieUser\w3.tif");
Windows.System.UserProfile.LockScreen.RequestSetImageFeedAsync(u);
I am trying to change the lock screen in a Windows forms application. I have managed to use WinRT libraries in Windows forms application and there are two methods to change picture one is written above and other is as below
LockScreen.SetImageFileAsync(); //But it requires IStorageFile passed in method
I have pictures stored in "resources" folder, is there any method to convert/use these pictures as IStorageFile?
File path is correct but when I tries to run it shows an error message that
Element not found. (Exception from HRESULT: 0x80070490)
LockScreen.RequestSetImageFeedAsync is supposed to be called with a Uri pointing to an RSS feed, not an image. This method is deprecated in Windows 10.
You can use StorageFile.GetFileFromApplicationUriAsync to get files from the application's resources folder.
I'm having an issue here, I developed an application in C# which creates a text file. This text file is saved in the X:\Public\3rd\ASN\, the problem is that in development the files are created and saved with no issues but once I move the application into our Web Server the appplication fails and it throws out this error "Could not find a part of the path X:\Public\3rd\ASN\1175_0001.txt".
This is the code I'm using to saved the file in the directory:
w = File.CreateText("X:\Public\Public\3rd\ASN\1175ASN_0001.txt");
Keep in mind that this directory is another server.
Any help will be really appreciate it.
your X drive is a mapped network drive. You need to use the network url eg \\server\directory\Public\3rd\ASN\1175_0001.txt
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.