|
Hi
I am in the process of developing a cloud backup software. The application is a desktop application developed using C#.
I need to add an option to stop/pause the backup if the computer was connected to a 3G network to save cost for the user.
I cannot seem to be able to find any example on how this can be achieved, there are some examples for Windows Phone and Windows Store Apps but I cannot find anything that can check if the connection type is a WiFi/Ethernet or 3G the latter is my main concern.
I tried a test application to enumerate the networks:
Console.WriteLine("checking network interfaces\n");
NetworkInterface[] interfaces = NetworkInterface.GetAllNetworkInterfaces();
foreach (var networkInterface in interfaces)
{
Console.WriteLine("Interface Detected");
Console.WriteLine("Description: "+networkInterface.Description);
Console.WriteLine("ID: " + networkInterface.Id);
Console.WriteLine("Name: " + networkInterface.Name);
Console.WriteLine("Interface Type: " + networkInterface.NetworkInterfaceType);
Console.WriteLine("Operational Status: " + networkInterface.OperationalStatus.ToString());
Console.WriteLine("Speed: " + networkInterface.Speed.ToString());
Console.WriteLine("Supports Multicast: " + networkInterface.SupportsMulticast.ToString());
Console.WriteLine("#########################################################\n");
}
The above code list my 3G connection as PPP which can be either ADSL or 3G. I am not sure if I can differentiate using some other options or APIs
I need a clear way to distinguish between those networks and so far I cannot find a way of doing so.
Can someone please help?
modified 24-Dec-12 7:12am.
|
|
|
|
|
|
Thats for Windows Phone, sadly the solution does not work with desktop applications.
|
|
|
|
|
Good morning,
I have a problem with the code below....when I receive answer from my clients, if they are connected, ping class answer twice. The problem is that I have to put the answers in a richtextbox I would avoid to see some double entry !
Thanks in advance !!
foreach (string PC in primaColonnaPc)
{
try
{
Ping x = new Ping();
PingReply reply = x.Send(PC);
if (reply.Status == IPStatus.Success)
{
valore = PC + " OK\r";
f2.riceviDati = valore;
}
else
valore =("ATTENZIONE: " + PC + "ERROR\r");
f2.riceviDati = valore;
}
catch (Exception)
{
valore =("ATTENZIONE:" + PC + ": WS not found\r");
f2.riceviDati = valore;
}
|
|
|
|
|
i am creating an asp.net application in which i have UploadImage.aspx page and user control
how would i create an object of Partial class UploadImage.cs in usercontrol.cs
Thanks for any help you might be able to provide with this problem,
|
|
|
|
|
Hi
Write the below in usercontrol
UploadImage objname = new UploadImage()
Regards
Naina
Naina
|
|
|
|
|
Hello,
I have declared a null array but when i try to use this array to store my values, it gives me an error as "use of unassigned local variable".
I donno whats wrong.
here is my code
double[] strPLatitude;
if (dr.HasRows)
{
while (dr.Read())
{
strPLatitude[i] = Convert.ToDouble(dr["latitude"].ToString());
i++;
}
}
|
|
|
|
|
You must allocate some space to it before you can store anything in it. Something like:
if (dr.HasRows)
{
strPLatitude = new double[N];
while (dr.Read())
{
You are also incrementing the variable i ; are you sure you initialised it somewhere?
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Yes i have initialized variable i
And data in my database table would increase with time. hence it's not possible to allocate a space to the array, since i don't know how much records exist in my table
|
|
|
|
|
Then use a List or something. We tend not to use arrays in C#.
|
|
|
|
|
Actually, you do know what's wrong: you're using an unassigned local variable. It will even tell you that strPLatitude is the culprit.
How to fix? Assign something to it, obviously. Most C# compile errors are easy like that.
You wanted a null array? Then make a null array: double[] strPLatitude = null;
That doesn't make the code work, I grant you, but it fixes this problem.
However, this:
tashee wrote: declared a null array but when i try to use this array to store my values Reveals a deeper problem. You can't use something that doesn't exist. Like Richard wrote, "You must allocate some space to it before you can store anything in it". Your reply to him seems to imply you didn't really get it.
This is like saying "I have a place where a bookshelf should go but there isn't one there yet, why do things go wrong when I try to store books in it?"
Don't use something that doesn't exist. You need an actual bookshelf, not just a place where a bookshelf could go.
PIEBALDconsult suggest you use a List, you should probably do that. Be sure to Add[^] the items to the list, don't try to stuff them into positions that do not exist.
|
|
|
|
|
Hello,
Im doing a big final project that manages a dive shop.
This application will have data base.
What im looking for is some example of solution that works with data base(connect to DB , SQL , Query) that i can take and modify it for my needs.
Thanks.
|
|
|
|
|
I can offer you some insight into creating a Data Access Layer.
DatabaseAccessor[^]
There are many similar articles on here.
|
|
|
|
|
I understand that article is from 2007, but I'd completely disregard it. It was completely bad practice even "back then". Definitely is horrible practice today. Use a proper data access layer like EF, nHibernate, etc. At the very least, if you use barebones ADO.NET, you should not write queries in the C# code like that. Completely vulnerable to a script kiddie who knows SQL injection.
|
|
|
|
|
SledgeHammer01 wrote: Completely vulnerable to a script kiddie who knows SQL injection
Bullshit -- it fully and easily supports parameters so there's no reason a developer has to leave himself open to that.
SledgeHammer01 wrote: EF, nHibernate, etc
And what do you think they do in the background? Exactly the same things I do. Everything has to go through a command and connection eventually; I cut out the middle man. Additionally, those tools may not support whatever database the OP has to use, whereas there is probably an ADO.net connector for it.
|
|
|
|
|
SledgeHammer01 wrote: It was completely bad practice even "back then".
Nonsense.
SledgeHammer01 wrote: you should not write queries in the C# code like that. Completely vulnerable to a script kiddie who knows SQL injection.
You and I must have completely different definitions of SQL injection then.
I don't see anything in there that suggests anything at all like that.
|
|
|
|
|
Most of the ORM providers are bult upon ADO.NET.
but personally I dont think there is anything wrong with using ADO.NET, SQL Injection is only possible when there is a lack of parameterised queries.
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
|
|
|
|
|
Just do a search in the articles section on this site.
There are a number of good samples and articles here.
|
|
|
|
|
Actually i have one local area map i want to mark my location in one particular area in that local map.....How can i mark my location????
Pls give article or coding related this concept.
For Example i have America map means i want to specific my location in new work...how we can do this????
|
|
|
|
|
Not google maps so which mapping system?
What are you using to query the map? C#, JavaScript etc?
Are you stuck? If so where and what have you tried?
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
|
|
|
|
|
i had america map(dynamic map) in my web page. In this map ,while i'm moving mouse to some states position , want to shows like that state information in chat box or some message box i.e. state name, weather-condition,etc...
I'm doing this project in c#.net....so pls guide me....
|
|
|
|
|
chat application in asp.net c# workflow
|
|
|
|
|
with that little help on what your problem is or what help you need to start this project I would recommend that you have a read here
Just another chat application using SignalR[^]
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
|
|
|
|
|
I am developing an c# application and it uses many .net assemblies. For some reason i need to move a dll to program files folder and that dll depends on many other assembly present in the application folder and this makes me to copy all dependent dlls to programfiles folder. This will cause duplication of dll in both application and programfiles directory. I know that moving dependent assembly to GAC will resolve this issue but i shound not put many assembly in GAC. So please suggest a way to make .Net dll to reference its dependent dlls.
modified 23-Dec-12 0:22am.
|
|
|
|
|
whoever reading this actually i am into a project where we have to make an application that should generate a website as per the requirements of the user. its kind of web-portal. so if any body coould help.
|
|
|
|