|
Well the FileStream constructor goes like this:
FileStream( string path,FileMode mode );
Now, FileMode is an enum with member names:
Append, Create, CreateNew, Open, OpenOrCreate and Truncate.
If you use FileMode.Create it will overwrite the old file or create a new one if the file doesn't exist.
Hope this helps.
|
|
|
|
|
|
Hi!
I'vw been having some odd problems with connecting elements in Dundas diagram. I have an Element with 3 ConnectionPoints ( on is an input, and two ara outputs ) and when I try to connect a second Element's input to one of the outputs it always connects to the same ConnectionPoint no mater which I specify in the code. Like:
ElementFunctionality.ConnectElements( myConnector , TheOtherPoint , myElement.ConnectionPoints[ "Yes" ] );
//and
ElementFunctionality.ConnectElements( myConnector , TheOtherPoint , myElement.ConnectionPoints[ "No" ] );
will both connect to the "Yes" ConnectionPoint of the elment. I've even tried connecting manualy without using the ConnectElements function. I'm realy out of ideas.
Can someone help? Oh, and here is a screenshot.
|
|
|
|
|
Try support@dundas.com
Regards,
Nish
|
|
|
|
|
Hi
I have been trying to get my code working for days now, but I have run out of ideas of what could be wrong.
My problem is that I have a program where I want to save a file path from an openfiledialog into a XML document. It sounds pretty simple, but I keep getting an XML error, saying that my XML file does not exist :-S Even though it is the correct path.
I was wondering if anyone had a piece of code, which does the above-mentioned? That way I may be able to find a solution to my problem.
//Nick
|
|
|
|
|
It would help if you posted a code fragment.
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
public class ClassFunctions : FormMain
{
private string strXMLLocation = @"..\..\WallpaperDatabase.xml";
public string fxGetFileName()
{
string strFileName = "";
this.openFileDialog1.Multiselect = false;
this.openFileDialog1.ShowDialog();
if (File.Exists(openFileDialog1.FileName))
{
strFileName = openFileDialog1.FileName;
}
return strFileName;
}
public string fxGetString()
{
string strFileName = "";
this.openFileDialog1.Multiselect = false;
this.openFileDialog1.ShowDialog();
if(File.Exists(openFileDialog1.FileName))
{
strFileName = this.openFileDialog1.FileName.ToString();
}
this.openFileDialog1.Dispose();
return strFileName;
}
public void fxAddPicture()
{
string strFilePath = fxGetFileName();
string insertXML;
XmlDocument xdoc = null;
XmlTextReader xreader = null;
XmlDocumentFragment xdocFrag = null;
try
{
xdoc = new XmlDocument();
xreader = new XmlTextReader(strXMLLocation);
xreader.Read();
xdoc.Load(xreader);
xreader.Close();
insertXML = "<Wallpaper><FileName>" + "test" + "</FileName><FilePath>" + strFilePath + "</FilePath></Wallpaper>";
xdocFrag = xdoc.CreateDocumentFragment();
xdocFrag.InnerXml = insertXML;
xdoc.DocumentElement.AppendChild(xdocFrag);
xdoc.Save(strXMLLocation);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
}
Here are the two functions within my class which are supposed to do the job J
//Nick
|
|
|
|
|
Perhaps you should try
private string strXMLLocation = Application.StartupPath + @"..\..\WallpaperDatabase.xml";
|
|
|
|
|
Adis H. wrote: Perhaps you should try
private string strXMLLocation = Application.StartupPath + @"..\..\WallpaperDatabase.xml";
When i try that i get the following error:
The syntax in the filename, the folder or the disk unit is incorrect.
but the XML file does exist.
|
|
|
|
|
Sorry make that:
private string strXMLLocation = Application.StartupPath + @"\..\..\WallpaperDatabase.xml";
You see the StartupPath returns a path like C:\blah_blah\App_Folder
without the "\" at the end, so you need to add it.
|
|
|
|
|
Thanks a lot it is working just fine now
|
|
|
|
|
I have a "List<CSomeObject> someList" with several properties. When I assign my "dataGridView.DataSource = someList" it populates the DataGridView, but the order of the properties is seemingly random. Can I specify the order somehow? Also, can I change the name of the columns instead of being forced to use the Property name?
-- modified at 15:45 Monday 12th June, 2006
|
|
|
|
|
You can create your own columns for the DataGridView by setting its AutoGenerateColumns property to false and then adding DataGridViewColumn-derived (e.g. DataGridViewTextBoxColumn ) columns to it with your desired HeaderText and DataPropertyName properties, in the order you want, preferably prior to data binding.
--
I've killed again, haven't I?
|
|
|
|
|
How do I call a different application from the one I am running on a CE.net device in C#. It appears that the Process class is not supported in the CF.
|
|
|
|
|
|
|
Use Mockup Studio.Net!
- It's easier to make than to correct a mistake.
|
|
|
|
|
Hello,
I have a MDI child form full of controls (mainly text boxes), which save their values to the underlying object on the Validated event. My problem is that the Validated event is not raised when the user clicks on a toolstrip button, since apparently the text box never loses focus.
I had this same problem in .NET 1.x with the Toolbar control, but it was easy to solve since no matter the button, the save event was raised: ButtonClicked . There I could force the Validated event (by setting focus to the toolbar and back to the control) and then proceed to do whatever the button was supposed to do.
The problem is that with the ToolStrip control every button raises its own event, and thus I would have to force the event in every handler of every window, and for obvious reasons I don't want to. I have serached but I have not found a ButtonClick or similar event in the ToolStrip control.
So, does anyone have an idea of an easy way to solve this?
[EDIT: I just found out the CausedValidation property on the ToolStrip , but after trying it it still doesn't work.]
[EDIT AGAIN: I had tried the ItemClicked event and it didn't seem to work, but now I know why: I was handling it on the ToolStrip on the MDI child (which is merged to a ToolStrip in the parent form). Now that I handled it in the parent window, it works. The problem here is I can't stop the raising of the Click event for the toolstrip item if validation fails].
Thanks in advance,
Luis Alonso Ramos
Intelectix
Chihuahua, Mexico Not much here: My CP Blog!
-- modified at 15:17 Monday 12th June, 2006
|
|
|
|
|
I'm trying to put together an enhanced message box that acts as a progress view with a timeout.
Here is the idea:
I call a Dialog box that displays my title and a progress bar. It progresses the bar once a second to show that it is doing something. It also calls my routine, which will do it's thing.
If the progress times out, then kill my routine and say "Operation Timed Out", with an OK button. Clicking on the Ok button returns DialogResult.Cancel (to say the operation failed)
If my routine returns successfully, then return DialogResult.OK and remove the dialog box. (No interaction with the user required).
The main idea is that I can do some network operations in the background, show the user progress in a pop-up box, and have a network timeout - all in one package.
Has anyone written one of these, or have suggestions on where I should start?
Progress thus far:
I have the dialog box nicely written (with delegates so I can update the progress bar and associated messages). I'm not sure on how to move forward with the timeout stuff.
|
|
|
|
|
ahall@mirapoint.com wrote: Has anyone written one of these, or have suggestions on where I should start?
http://www.codeproject.com/cs/miscctrl/progressdialog.asp[^]
ahall@mirapoint.com wrote: I'm not sure on how to move forward with the timeout stuff.
Add a timer to the dialog!
You know you're a Land Rover owner when the best route from point A to point B is through the mud.
EdLast modified: 12 June 2006 14:07:39 --
|
|
|
|
|
The progress dialog mentioned was pretty good code and gave me a lot of what I needed.
Adding a timer, and a background worker finished it off. Generically, it might take a little more work, but not much more.
Thanks for the pointers.
|
|
|
|
|
Thread title doesnt really explain this question to well. Hopefully this will make things a little clearer:
Lets say I have the following classes
class MyBase
{
string str1;
public MyBase(string str1)
{
this.str1 = str1;
}
}
class MyChild : MyBase
{
bool b1;
public MyChild(bool b1, MyBase baseData)
{
this.b1 = b1
???? = baseData
}
}
Without writing reams of code to explicity do it, is there a way of getting the MyChild constructor parameter baseData into the base instance of the MyChild object?
|
|
|
|
|
Maybe you're trying to do this?
class MyChild : MyBase {
bool b1;
public MyChild(bool b1, string str1) : base(str1) {
this.b1 = b1;
}
}
Logifusion[^]
|
|
|
|
|
First of all, The object of the child class contains the portion of data from the base class. You can replace that portion with any object of the base class, but your MyChild code is not working the way you anticipated.
I think you are confused about how to handle class relationship. There are two approaches here:
1) inheritance ("Car is a Vehicle")
2) composition ("Car has an Engine")
MyChild class code looks more like composition relation, namely, it contains an object of MyBase. The code should be something like this:
class MyChild
{
public MyChild(bool bl, MyBase baseData)
{
this.bl = bl;
this.baseData = baseData;
}
private bool bl;
private MyBase baseData;
}
- It's easier to make than to correct a mistake.
|
|
|
|
|
I am using a DataGridView to display a List of objects that change frequently (at a rate of up to 4 times per second.) I am using a BindingSource as the DataSource for the DataGridView and on every datachange event I set the BindingSource's DataSource to the List of objects. This results in a bunch of flicker.
I attempted to fix this using SuspendLayout and ResumeLayout, but haven't seen a difference. Any ideas?
|
|
|
|