|
|
I', trying to download a rapidshare file using a premium account but I'm stuck.
My Download() Method:
private void Download()
{
using (WebClient wcDownload = new WebClient())
{
try
{
webRequest = (HttpWebRequest)WebRequest.Create(txtUrl.Text);
webRequest.PreAuthenticate = true;
//**QUESTION:**I'm not very sure if I should use NetworkCredential to authenticate myself.
NetworkCredential networkCredential = new NetworkCredential("username", "password", "rapidshare.com");
webRequest.Credentials = networkCredential;
webResponse = (HttpWebResponse)webRequest.GetResponse();
// Open the URL for download
strResponse = wcDownload.OpenRead(txtUrl.Text);
// Create a new file stream where we will be saving the data (local drive)
strLocal = new FileStream(txtPath.Text, FileMode.Create, FileAccess.Write, FileShare.None);
// It will store the current number of bytes we retrieved from the server
int bytesSize = 0;
// A buffer for storing and writing the data retrieved from the server
byte[] downBuffer = new byte[2048];
// Loop through the buffer until the buffer is empty
while ((bytesSize = strResponse.Read(downBuffer, 0, downBuffer.Length)) > 0)
{
// Write the data from the buffer to the local hard drive
strLocal.Write(downBuffer, 0, bytesSize);
}
}
finally
{
// close the streams when job done
strResponse.Close();
strLocal.Close();
}
}
}
**QUESTION:**I'm not very sure if I should use NetworkCredential to authenticate myself.
Any ideas if authentication should be done via Cookie? If yes, how? HttpCookie?
Thanks.
|
|
|
|
|
With other programs like "Internet Download Manager" it works
|
|
|
|
|
|
I do test it tanks 4 the tip
|
|
|
|
|
Greetings all,
I was hoping to glean some advice from some of you pros out there. I am currently enrolled in an application developer program with New Horizons and I have very little actual programming experience other than HTML. By the time I'm done with all of the courses I will have taken 5 exams which I guess will give me the MCTS cert. The exams they have listed that I will take are:
70-536 = Dot Net Framework 2.0 Foundation
70-528 = Dot Net Framework 2.0 Web Applications
70-526 = Dot Net Framework 2.0 Windows Applications
70-529 = Dot Net Distributed Applications
70-431 = SQL 2005 Certification
They are pretty much using all of the official Microsoft materials to teach the information. I checked out the Microsoft Certifications site and all of the materials that they have listed that you should have to prepare for each exam is pretty much what I have been given at NH. I'm currently starting MS-5160 Core Development with .Net Framework 2.0 today.
So here is my question:
First, I'm finishing up 2609A Introduction to C# and while I pretty much understand the basics of the language and the concepts behind it, I couldn't just sit down and start writing code. The Prerequisite for starting MS-5160 is a year of actual programming under your belt. Do I need to be proficient in at least being able to write C# code before I move on to more in depth studies? Also, what is the best way to actually get the practice of coding. It seems like there is a lot of material out there that teaches the concepts, but not near enough real life application practices where you go in an actually code productive solutions.
Any comments or suggestions?
|
|
|
|
|
I'm also busy doing the exams listed above. I have about 5 years of C# experience now, which I think is plenty, but loads of peeps here will have lots and lots of experience. The first exam, the Framework foundation is basicly explaining pretty much diffrences between the 1.1 and 2.0 framework. The exam is pretty simple in my opinion. However the technology specialist exams do require some sort of experience (TS exams are Web, Win & Distro).
I'f you're already a little into C#, I recommend fooling around a lot. Set yourself a goal like creating an app which communicates with a SQL Server, also try other databases but become familiar with talking to databases. I bought the book MS .NET Framework 2.0 Application Development Foundation (ISBN-13 : 978-0-7356-2277-7) to prepare for the 70-536 exam. You'll be able to pass that exam pretty easy. After you've done that you should have a pretty good foundation to get more and more familiar with the code. The best way to do that, is do the coding. Set yourself a goal, develop a project plan and code. Ofcourse you'll run into problems, but that's why codeproject is here
|
|
|
|
|
"I recommend fooling around a lot" - Eduard Keiholz in the C# forum
|
|
|
|
|
For C# experience, I'd suggest downloading a few of the great articles (source samples) right from this site (pick some that you're familiar with in everyday life). Run the demos to see how it works, then set up a debug session and learn from the code. Once you've done that, pick a target (for example a name/address lookup app) and code it, using the other source as reference. Syntax is easy. Designing using OO concepts is a bit tougher to do correctly.
Hopefully mistakes will become apparent and all of it will give you a better understanding.
My other suggestion would be to do a google on C# skills tests.
Good luck to you!
|
|
|
|
|
No matter how much you read, doing the stuff is the best. Assuming that you have Visual Studio on a machine, you could go to Coding4Fun and look at some of the coding examples. Some of the authors do a very good job explaining what to do and why. It can also give you that boost to go from 'okay...what must I do to write code' to 'okay...what can I code next'.
Over time you'll start to have questions like when do I create a class library, why would I want to overload a method, and stuff like that.
Regardless of what level you are at, if you try something and fail or something goes over your head, we are here to help.
|
|
|
|
|
Hi everybody,
Im creating a c# windows application in framework 2.0,i had created textbox dynamically so that i want to produce tree view structure as the no of textbox i created.I Need only one root node.
The structure is
TextBox
|
|_TextBox1
|_TextBox2
|_TextBox3....
But Im getting the tree structure as
TextBox
|
|_TextBox1
TextBox
|
|_TextBox2
TextBox
|
|_TextBox3
The Code i used is below
int n = 25;
int m = 1;
private void BtnAddControl_Click(object sender, EventArgs e)
{
TextBox txtBox = new TextBox();
txtBox.Text = "TextBox" + m;
txtBox.TabIndex=m;
txtBox.Tag=m;
txtBox.Location = new System.Drawing.Point(10, n);
txtBox.Size = new System.Drawing.Size(70, 20);
txtBox.Name = "TextBox" + m;
txtBox.Click +=new EventHandler(txtBox_Click);
this.Controls.Add(txtBox);
TreeNode root = new TreeNode("TextBox");
root.Nodes.Add(txtBox.Name);
TV.Nodes.Add(root); //TV Treeview name
TV.ExpandAll();
n = n + 20;
m++;
}
How should i accomplish this..
Kanna
|
|
|
|
|
Dotnetkanna wrote: n = n + 20;
m++;
Anyway, try like this...
<code>TreeNode parentNode = new TreeNode();
parentNode.Text = "Whatever";
mainTreeView.Nodes.Add(parentNode);
for(int count = 0; count < 10; count++)
{
parentNode.Nodes.Add(count.ToString());
} </code>
|
|
|
|
|
Hi Kanna.
The reason is because you are creating a new node every time the button is clicked and adding that newly created node to the root level of the Tree itself. I would suggest creating the parent node as a member level variable and then add your new TreeNodes to that parent node rather than to the TreeView.
|
|
|
|
|
If I wanted a service to be discoverable over a LAN would I use UDP multicasting?
Is there a better option?
|
|
|
|
|
|
|
I have created a ActiveX DLL in Visual Basic 6.0 SP5 with one function that returns a String of "Hello World From VB6 DLL". I then register the DLL using RegSvr32 <path and file name of VB6 DLL>. Next, I create a new WebService project in C# using Visual Studio 2005 .NET. In this project, I do an Add Reference, choose the COM tab, and select the DLL I just created in VB6. I add a using directive (using VB6ComTest;) to my Web Service class then proceed to add WebMethod that will call that VB6 function:
[WebMethod]
public string GetTestString()
{
VB6ComTest.MyVBTestClassClass test = new MyVBTestClassClass();
string a = test.HelloWorld();
return a;
}
I'm new to Web Services and using Interop in .NET. I've read that Interop uses interfaces so that may explain why the "Class" is named "MyVBTestClassClass". The intellisense is showing me three (3) items within VB6ComTest and they are: _MyVBTestClass (an interface), MyVBTestClass (an interface), and finally MyVBTestClassClass (a class).
When calling the this GetTestString() WebMethod from Internet Explorer (using the .asmx) or from a console application I have created in the same solution, I get this error every single time without fail:
System.Web.Services.Protocols.SoapException was unhandled
System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.InvalidCastException: Unable to cast COM object of type 'VB6ComTest.MyVBTestClassClass' to interface type 'VB6ComTest._MyVBTestClass'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{9F789AFC-7C61-4D4F-8EDF-35866D18EEEE}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).\n at VB6ComTest.MyVBTestClassClass.HelloWorld()
I've been battling this for three full work days now and would great appreciate any assistance.
Thank you.
Jason
|
|
|
|
|
Nxorable wrote: Next, I create a new WebService project in C# using Visual Studio 2005 .NET.
Nxorable wrote: I've been battling this for three full work days now and would great appreciate any assistance.
Have you created a C# Winforms project and used the ActiveX control successfully in there?
|
|
|
|
|
Thanks for your reply.
Yes, I have tried directly referencing the DLL in the Console application and it works fine. I have also created a .NET class library that wraps this VB6 DLL and then referenced the the .NET library from the Console app and that work fine too. The moment I try to reference the VB6 DLL from a .NET Web Service, I get this exception.
I've done a lot of research online and in Wrox books with no success. I've verified that ASP.NET and the IUSER account on my box have access to the COM library as well as the HKCR registry keys. I've registered and unregistered the DLL numerous times.
|
|
|
|
|
Well, if you are executing the "exact" same code in the Web Service that works in the console application then obviously the difference is the context. This means some problem like security, access/permissions, registry, etc.
|
|
|
|
|
I have a project write in c# (c/s) need to embed word controler
that is to say, the combox is used word controler instead. so that is free to edit content.
|
|
|
|
|
lockepeak wrote: the combox is used word controler instead
You mean you want a combo box in which you can type and change the value? Thast the default functionality when you add a new combo box.
|
|
|
|
|
I want to embed the word in the windows form.
|
|
|
|
|
lockepeak wrote: I want to embed the word in the windows form.
That still isn't understandable.
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
"I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless."
My website
|
|
|
|
|