|
Aaaaah.... the file name is passed on the command-line (as it were), so in Main you refer to it as args [ 0 ] .
When I write a WinForms app that does this I write a constructor that takes the filename
MyForm ( string FileName ) { ... }
and then in Main I use
System.Windows.Forms.Application.Run ( new MyForm ( args [ 0 ] ) ) ;
what you do with it from there is up to you.
|
|
|
|
|
Thank you very much... This was such a hard thing to search for because my only understanding of it included such common basic terms like, "Open with", file, load.
I was going crazy trying to figure out the proper way to search for this topic.
|
|
|
|
|
P.S.
In Main I test the length of the args array to determine which constructor to use.
Another way is to pass the args array to the constructor and have it decide how to proceed.
|
|
|
|
|
This is my third attempt at getting a c# app to modify an XML file , i dont know whats so difficult about this ive looked at all the examples i can find here and elsewhere but none of the code is making any sense to me .
All im trying to do is take the xml file below and change the value of <Value></Value> based on which botton i click without modifing the formating or anything because it has to be imported into a flash file .
<?xml version="1.0" encoding="unicode"?>
<StatusMonitor>
<CurrentStatus sourceurl="http://blah.net">
<item type="Entry">
<Value>Online</Value>
</item>
</CurrentStatus>
</StatusMonitor>
Can anyone take a look at myb very simple single formed app andhelp me get it working so i have something to learn from ?
http://rapidshare.com/files/43465047/test.zip.html
|
|
|
|
|
I can't access your file there.
But here's an easy way of changing the value in the xml.
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(fileName);
XmlNode valueNode = xmlDoc.DocumentElement.SelectSingleNode("//Value");
valueNode.InnerText = "New Value";
xmlDoc.Save(fileName);
-Larantz-
|
|
|
|
|
To get the formatting I want I use:
System.Xml.XmlWriterSettings WriterSettings = new System.Xml.XmlWriterSettings() ;
WriterSettings.Indent = true ;
WriterSettings.Encoding = System.Text.Encoding.UTF8 ;
WriterSettings.OmitXmlDeclaration = false ;
using
(
System.Xml.XmlWriter writer
=
System.Xml.XmlWriter.Create
(
File
,
WriterSettings
)
)
{
Doc.WriteTo ( writer ) ;
}
|
|
|
|
|
That's just asking for a future bug though ..
XmlDocument xmlDoc = new XmlDocument();xmlDoc.Load(fileName);
XmlNode valueNode
= xmlDoc.DocumentElement.SelectSingleNode(
"StatusMonitor/CurrentStatus[@sourceurl='http://blah.net']/Item[@type='Entry']/Value");
valueNode.InnerText = "New Value";
xmlDoc.Save(fileName);
Would be a better if more verbose approach.
I'm largely language agnostic
After a while they all bug me
|
|
|
|
|
MidwestLimey wrote: future bug
You mean job security?
|
|
|
|
|
A) Formatting isn't important in an XML document.
B) What's happening to your formatting that you don't like?
|
|
|
|
|
Dear All,
Is there any way that i could tell windows launch my application as a different user, ofcosue this can be achieved by right-clicking on it. IS there any way that I can do it programatically.
Thank you!
M. Nauman Yousuf
"Mess with the Best, Die like the rest"
|
|
|
|
|
|
Thx Ravi,
i hv started working on this lead
"Mess with the Best, Die like the rest"
|
|
|
|
|
Basically I want to do something like this:
Code:
on the .aspx page
setHorizontalLabels([<%# Function %>]);
"Function" being a function in my .aspx.cs that returns an array
I just can't seem to get my <% %> to be recognized within the script tag.
Any thoughts?
-----------------------------------------------------------
Completion Deadline: two days before the day after tomorrow
|
|
|
|
|
jgasm wrote: Basically I want to do something like this:
You cant always get what you want,
But if you try sometime, yeah,
You just might find you get what you need!
Also try posting in a "web development forum" like ASP.NET or something
|
|
|
|
|
Looking to automate business process in form of xml tags(like IO,Registry,ACL operations etc) and writing a C# wrapper to execute the same.
Is there any project or library available, so that i dont have to re-invent the wheel.
Thanks!
h.
|
|
|
|
|
Have you looked at the Windows Workflow in the 3.0 framework?
Michael
|
|
|
|
|
Oh my my, we are still upgrading to .Net 2
|
|
|
|
|
I want to Download a File from RapidShare using this Code
try<br />
{<br />
string destFileName = _DirectoryPath + "\\" + FileName;<br />
destFileName = destFileName.Replace("/", " ").Replace("%20", " ");<br />
<br />
if (File.Exists(destFileName) == false)<br />
{<br />
IWebProxy proxy = null;<br />
if (ProxyUri != null && ProxyUri != string.Empty)<br />
{<br />
proxy = new WebProxy(ProxyUri, true);<br />
proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;<br />
}<br />
<br />
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(_DocumentUrl);<br />
if (proxy != null)<br />
{<br />
request.Proxy = proxy;<br />
}<br />
HttpWebResponse response = (HttpWebResponse)request.GetResponse();<br />
stream = response.GetResponseStream();<br />
<br />
byte[] inBuffer = ReadFully(stream, 32768);<br />
<br />
fstream = new FileStream (destFileName, FileMode.OpenOrCreate, FileAccess.Write);<br />
fstream.Write(inBuffer, 0, inBuffer.Length);<br />
<br />
<br />
fstream.Close();<br />
stream.Close(); <br />
}<br />
_IsDownloadSuccessful = true;<br />
_IsDownloading = false;<br />
<br />
DownloadCompleted(this, _IsDownloadSuccessful);<br />
}<br />
catch
standard Downloads like "http://www.web.com/file.zip" works fine.
Downloads like "http://rs125dt.rapidshare.com/files/41109314/dl/Sega_PSP_Emu.rar" quit after 6kb (login at rapidshare is already done)
Is there a way to fix this?
|
|
|
|
|
|
|
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?
|
|
|
|