|
Ok, after looking at your code, AND the other replies, there are areas that do have real problems.
LOGICAL ERROR:
public string acctype
{
get { return _acctype; }
set {
if (_acctype = "savings" || _acctype = "current")
{
_acctype = value;
}
else
{
_acctype = "";
}
}
}
In your test, you are assigning the strings to _acctype, what you accomplish will not be what you want, as _acctype will always be assigned the contents of value.
QUESTIONABLE on what you are attempting to do:
public int credit(_balance , _amount)
{
return _balance + _amount;
}
public int debit(_balance , _amount)
{
return _balance - _amount;
}
you are overriding the internal private class variables _balance and _amount with what you pass in as _balance and _amount. Im not sure what you intended to do here. Is the class variable _amount needed? Are you trying to update _balance, or are you just attempting to deliver the would be changes just for the values or to update externally?
-Later!
-WB-
|
|
|
|
|
you are getting the error because you are not specifying the data type for the method arguments:
public int credit(_balance , _amount)
{
return _balance + _amount;
}
public int debit(_balance , _amount)
{
return _balance - _amount;
}
TRY:
public int credit(<code>int</code> _balance , <code>int</code> _amount)
{
return _balance + _amount;
}
public int debit(<code>int</code> _balance , <code>int</code> _amount)
{
return _balance - _amount;
}
|
|
|
|
|
I can't seem to find any info on how to make my application open files.
I know this sounds crazy because it's so fundamental but how do I reference a file that was used to start the application? I can choose my program to open a certain file type but of course once I click that file I get an error because I have no code that handles that situation.
Thanks
|
|
|
|
|
Okay maybe a little clarification through an example:
When you use something like "FileDialog dialog" you get the filename through "dialog.Filename" is there something like this for when you start an application up through a file?
|
|
|
|
|
You mean you want to associate a file type with your application? So when you double-click a file of that type in the Explorer your application gets launched to open it?
That's (usually) done through Explorer. My Computer|Tools|Folder Options...|File Types|New
|
|
|
|
|
No, I know how to do that... My problem is with opening a file with my application. How do I handle the file once it is used to launch the application? What references that file?
Seems like a very common thing to implement but either I'm having one hell of a brain hiccup or I just can't find info on it anywhere.
|
|
|
|
|
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?
|
|
|
|
|