Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I want to extract a text file located on a remote computer to my computer using c# programming language.
How can I do it?
I tried using file.copy method, but was unable to do it.
Can anyone suggest some other method.
Thanks in advance
If you're using C# with file.copy you have to have the remote drive mapped to your computer and you have to be authenticated. I'm betting the problem you are having is simply related to the fact that you don't have permission to get the file you are trying to get.
If you have a valid username/pw for the remote machine, map the drive:
http://windows.microsoft.com/en-us/windows/create-shortcut-map-network-drive#1TC=windows-7
If you still have issues it's likely something on the remote machine stopping you.
Edit:
If you are attempting to access a drive on the same network attempt to visit the URI in windows explorer. If you can get to it than there is another issue entirely. If you cannot get to it or if it asks for user or PW you simply don't have permission to be there.
Edit 2:
Pro-tip: Avoid trying to look like you are attempting to "hack" something. I guarantee you you will be flamed and down-voted to oblivion as obvious by the other responses you've gotten.
EDIT 3:
Another stack overflow article talking about the same thing with c#
Accessing a Shared File (UNC) From a Remote, Non-Trusted Domain With Credentials
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I need to backup a file located on a remote machine using C#.
For example: "\server1\docs\test.txt" needs to be copied or moved to "\server1\docs\backup\test.txt."
Question: When I use File.Copy, does that move the file from the server, to my machine, back to the server -- essentially round-tripping the file across the network?
I'd like to avoid round-tripping.
Details: Both machines are Windows OS's on the same Domain.
Note: I want you guys to know that I have searched all over for the answer to this question, however, I have found contradicting answers. I'd like to know definitively. Thank you for your time.
You should run this from the server in order to avoid round-tripping the data. Keep in mind that if the files you're trying to work on are located on the same hard drive, moving them will be faster than copying them.
Just looking at the source code of C# (http://referencesource.microsoft.com/#mscorlib/system/io/file.cs,4a0905e7dc32d77d) it seems that File.Copy calls Win32Native.CopyFile function. To be honest I don't know exactly what it does, I mean I never saw the code, but I guess there's no magic and it reads the bytes from the remote computer and writes to the other remote computer.
Edit
One alternative is to login into the remote server via powershell (you can invoke ps scripts via C#) and execute the command to copy to the 2nd machine.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I am currently trying to work on a project in c# in which I want to access/browse the remote drives of a system like a local drive , can anyone help.
thanks
have you tried using "Map a network drive" option in Windows Explorer? it works exactly like u have described, and it doesn't need to use webservice (from the tags u have chosen for the question).
you can programatically map a network drive using http://www.codeproject.com/Articles/90143/Mapping-Network-Drive-using-C
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
The site provides links as http://www.example.com/download.php?id=53979 . I know that this is a pdf file and want to download it via a C# program. Is this possible and if yes, how?
In order to download a file, you simply need to use the WebClient object like in the question referenced above:
using (var client = new WebClient())
client.DownloadFile("http://www.datasheet4u.com/download.php?id=53979", "datasheet.pdf");
What makes your case slightly different has nothing to do with the server being written in PHP or anything like that. The link you provided (http://www.datasheet4u.com/datasheet/L/M/7/LM741_NationalSemiconductor.pdf.html) appears to be checking Referer headers when serving the file. This is likely some attempt on their part to prevent what you're trying to do, but it doesn't actually prevent it.
All you need to do is add a Referer header to the request. Something like this:
using (var client = new WebClient())
{
client.Headers.Add("Referer","http://www.datasheet4u.com/datasheet/L/M/7/LM741_NationalSemiconductor.pdf.html");
client.DownloadFile("http://www.datasheet4u.com/download.php?id=53979", "datasheet.pdf");
}
The method for downloading the file is still the same. The server just requires that you send an extra piece of information in the request.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Improve this question
I have dll that using in one my application. This dll connect to one remote server and post and get some data.
When I run this dll in my application, How I can find IP address of this remote server?
Dll written by C++.
Possible find that?
I am using Win7.
Regards,
You can check the endpoints with netstat: netstat -an -p tcp
It comes with Windows.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
i have 200 terminals (Windows-mobile) that connect to the server Through WIFI
how i can transfer any file to all of them ?
is there any tool or can i get any C# sample code for this ?
thanks in advance
You should write some sw on the mobiles to sink the file instead of pushing on them. So each user can ask the server for transfer the file. If the file you need to transfer is a deploy of an application, you can even consider some strategy of auto upgrade as described here: http://msdn.microsoft.com/en-us/library/aa446487.aspx
You could create a log-on script assuming you have Active Directory and a friendly system administrator.
http://www.rlmueller.net/LogonScriptFAQ.htm
Microsoft have a non-free tool called System Center Configuration Manager that will do what you want. You need to install the client app on the phones first, then they poll the server for updates.
This is likely to be massive overkill for what you want but it's hard to be sure from the question.