This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
C# Connecting Through Proxy
I've tried doing this for a long time in many different ways but nothing seems to work. Essentially I want to create a proxy checker in C# that checks it by actually going to a page (e.g. http://google.com/ncr) and determines from there if it got there or not.
Is this even possible?
If it is a http proxy
bool OK = false;
try
{
WebClient wc = new WebClient();
wc.Proxy = new WebProxy(Host, Port);
wc.DownloadString("http://google.com/ncr");
OK = true;
}
catch{}
Related
This question already has answers here:
How to detect working internet connection in C#?
(7 answers)
Windows Service to detect network change event
(1 answer)
Closed 2 years ago.
I am using following code to check if my app is connected to internet
try
{
using (var client = new WebClient())
using (client.OpenRead("http://google.com/generate_204"))
return true;
}
catch
{
return false;
}
I want to check the connectivity of specific network adapter.
for example I have two internet connections. one is connected through WiFi and other one through ethernet cable both are from different ISP.
I only want to check the connectivity of Ethernet.
someone suggested socket.bind(). But I don't know how to use webclint() with socket.bind() kindly help with example
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I looking for a code to remove images from FTP but does'nt work
I tried to use this code but not work for me:
Dim FTPRequest As System.Net.FtpWebRequest = DirectCast(System.Net.WebRequest.Create("ftp://myftpname.es/Html/images/" & imagename), System.Net.FtpWebRequest)
FTPRequest.Credentials = New System.Net.NetworkCredential("FTPUsername", "FTPPassword")
FTPRequest.Method = System.Net.WebRequestMethods.Ftp.DeleteFile
FTPRequest.UsePassive = True
FTPRequest.UseBinary = True
FTPRequest.KeepAlive = False
How can I remove images from ftp?
Thanks
this code not remove the image from the ftp
That's because you never actually execute it, you just initialize it. To issue a WebRequest, you need to get its response:
var response = FTPRequest.GetResponse()
Have you tried using the FtpClient class?
Dim client as new System.Net.FtpClient.FtpClient()
client.Credentials = new NetworkCredential("FTPUsername", "FTPPassword")
client.Host = "ftp://myftpname.es"
client.Connect()
client.DeleteFile("Html/images/" & imageName)
This question already has answers here:
C# WebClient disable cache
(12 answers)
Closed 7 years ago.
I am using this code to get the return string from URL
webClient.Encoding = Encoding.UTF8;
response = webClient.DownloadString("http://somesite.com/code.php");
Console.Write(response);
the code.php looks like this
<?php
$data = file_get_contents('code.txt');
echo $data;
?>
The problem is when I change the contents of the code.txt file, the webClient.DownloadString() method returns the old contents of the code.txt file. When I open the URL http://somesite.com/code.php in a browser it works perfectly fine.
Any solutions will be appreciated!
My question seems to be duplicated but I don't really understand what is said here: C# WebClient disable cache
If anyone could explain and provide some example code it would be great!
Try disabling the cache on the WebClient
webClient.CachePolicy = new System.Net.Cache.RequestCachePolicy(System.Net.Cache.RequestCacheLevel.NoCacheNoStore);
MSDN Documentation on WebClient Cache
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
What is the correct way to create a single instance application?
How can I define my application to open only one time after click on its exe file over and over?
There are several related questions on Stack Overflow for Single Instance Applications:
This one seems to be the most apropriate: What is the correct way to create a single-instance application?
I've always done this at the application's entry point:
bool onlyInstance = false;
Mutex m = new Mutex(true, "MyUniqueMutextName", out onlyInstance);
if (!onlyInstance)
{
return;
}
GC.KeepAlive(m);
This question already has answers here:
The channel 'tcp' is already registered
(3 answers)
Closed 8 years ago.
I am trying to create two IPC channels
IpcChannel ipcChannel = new IpcChannel("DroolsClient");
ChannelServices.RegisterChannel(ipcChannel, false);
objec = (DroolsInterface.RulesEngineInterface)Activator.GetObject(typeof(DroolsInterface.RulesEngineInterface), "ipc://Drools/SreeniRemoteObj");
IpcChannel ipcChannel2 = new IpcChannel("ProxemClient");
ChannelServices.RegisterChannel(ipcChannel2, true);
objec2 = (ProxemProject.ProxemInterface)Activator.GetObject(typeof(ProxemProject.ProxemInterface), "ipc://ProxemProcess/SreeniRemoteObj");
But when it gets to the second ChannelServices it gives an error
The channel 'ipc' is already registered
Would anyone be kind enough to help please
See this question Two-way communication using IPC
The channel 'tcp' is already registered