|
I stand slightly extended.
|
|
|
|
|
Pete O'Hanlon wrote: if (MyEvent != null)
MyEvent(this /* This populates the sender object */, new EventArgs());
What's MyEvent. Is it object or method name.
Freshman
|
|
|
|
|
MyEvent was just an example for a name of an event. It could be any event that you want to use.
|
|
|
|
|
Pete O'Hanlon wrote: new EventArgs());
EventArgs.Empty I say!
|
|
|
|
|
leppie wrote: EventArgs.Empty I say!
MyEvent overloaded him. What do you think this would do?
|
|
|
|
|
Pete O'Hanlon wrote: MyEvent overloaded him. What do you think this would do?
Probably what you intended it to do?
EventArgs.Empty is just a an empty instance which is equivalent to new EventArgs().
|
|
|
|
|
Hello.
I have this wierd problem when im writing to a text file with data from a array
I have this method:
private void writeData()
{
StreamWriter writeData = new StreamWriter(saveMonsterSetBase.FileName, false);
for (int x = 0; x < MonsterSetBaseDataArray.Count; x++)
{
writeData.WriteLine(MonsterSetBaseDataArray[x]);
}
writeData.Close();
}
Which is trigged here:
saveMonsterSetBase.ShowDialog();
if (saveMonsterSetBase.FileName != "")
{
writeData();
}
It works fine and opens my saveFileDialog
But after I save it I get a "file not found" on some other method I use
This is some of the method:
StreamReader findMonsterStream = new StreamReader(@XMLmonsterLocation);
I get the error monster.txt (XMLmonsterLocation) is not found
It looks like the writedata changes the local path because it says
File not found in the path where I saved the file
Example:
The application and monster.txt (XMLmonsterLocation) is saved in D:\
I then use the saveFileDialog (I save a file to for example C:\) and when I access my method where I use the XMLmonsterLocation it says file not found in C:\
So I dont know why
Hope you understand
The StreamReader reads from a xml file that looks like this:
<config>
<monsterlocation>monster.txt</monsterlocation>
<monstersetbaselocation>MonsterSetBase.txt</monstersetbaselocation>
<monsterimagelocation>mobs\</monsterimagelocation>
<mapimagelocation>maps\</mapimagelocation>
<mapinfolocation>maps\maps.txt</mapinfolocation>
</config>
|
|
|
|
|
Hi,
Windows keeps a "current directory" for every process.
There are several ways to modify the curdir, browsing with an Open/SaveFileDialog is one of them;
check this: the second time you open such a dialog, it shows the folder you saw last.
You can prevent this from persisting by setting FileDialog.RestoreDirectory true.
In general you should not rely on the curdir, so basically your mistake is that the
StreamReader uses a relative path. If you want it to always read files from your EXE's folder
write code to enforce that; have a look at Application.StartUpPath
|
|
|
|
|
Hi
I know how to convert schema into class using XSDObjGenVSAddin tool. But, how can I convert C# class into xml schema? Is there any tool available for this?
Please advise. Thanks
Pankaj
modified on Wednesday, July 2, 2008 3:38 PM
|
|
|
|
|
pankazmittal wrote: But, how can I convert C# class into xml schema?
Very carefully.
led mike
|
|
|
|
|
|
Purpose : Read the contents of a CSV file and write it to a database in a varbinary field. Once written, read the contents and write it to a CSV file.
Issue: I am able to serialize and write the contents to the database.I am having issues when I deserilaize the file contents. I am getting an error "Trying to deserilaize an empty stream".
Please find below the code used to serialize and deserialize
private object SerializeFileContent(string filePath)
{
if (filePath != null)
{
//write the fielcontents to a byte array
FileStream st = new FileStream(filePath, FileMode.Open);
byte[] buffer = new byte[st.Length];
st.Read(buffer, 0, (int)st.Length);
st.Close();
//serilaize the bytearray and write it to a memory stream
MemoryStream serializedStream = new MemoryStream();
BinaryFormatter formatter = new BinaryFormatter();
formatter.Serialize(serializedStream,buffer);
//Read Memory Stream into Byte Array
int streamLength = Convert.ToInt32(serializedStream.Length);
byte[] serilaizedArray = new byte[streamLength];
serializedStream.Write(serilaizedArray,0,streamLength);
return serilaizedArray;
}
else
return null;
} public void DeserializeFileContent(string FileId,string filePath)
{
//read the file contents and write it to a stream
SqlConnection CCSProductCatalogArchiveConn = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["CatalogArchiveConnectionString"]);
SqlParameter sqlFileId = new SqlParameter("@FileId", SqlDbType.NVarChar,100);
sqlFileId .Value = FileId;
//Populates parameter array to be passed into DataUtil.ExecuteNonQuery
SqlParameter[] sqlParams = new SqlParameter[1];
sqlParams[0] = sqlFileId;
DataSet fileContents = DataUtil.LoadDataSet(CCSProductCatalogArchiveConn, "GetFileContents", true, sqlParams);
MemoryStream mstream = new MemoryStream();
StreamWriter writer = new StreamWriter((mstream);
writer.Write(fileContents);
mstream.Length
//Deserialize the contents
object o;
BinaryFormatter formatter = new BinaryFormatter();
o = (object) formatter.Deserialize(mstream);
}
Thanks
Hema
|
|
|
|
|
Member 3449442 wrote: MemoryStream mstream = new MemoryStream();
StreamWriter writer = new StreamWriter((mstream);
writer.Write(fileContents);
You need to reset the position to 0 after that
|
|
|
|
|
I am creating a ToolStrip that I have a DateTimePicker added on using the following code:
DateTimePicker FromDate = new DateTimePicker();
FromDate.Format = DateTimePickerFormat.Short;
MainToolStrip.Items.Add(new ToolStripControlHost(FromDate));
I am wanting to change the width of the DateTimePicker to be just large enough to fit the text needed. My thought was to measure the MaxDate value string using the font and that would be the width, like so:
Size dtps = TextRenderer.MeasureText(FromDate.MaxDate.ToShortDateString(), FromDate.Font);
FromDate.Size = dtps;
This works, except for one problem, it does not include the width for the drop down button on the DateTimePicker control, so it overlaps the text. I do not know how to get the width of the drop down button on the DateTimePicker, and my searches have been less than successful. Does anyone have a reference to where I can learn how to do this?
Also, is there any good references that go into some of this type of detail? Most of the books and websites I visit will teach you the basics of a control, like how to change the font, width, height, and common properties, but I would like to get a bit deeper with these items and really see what they can do. I think these books might be what I am looking for, but have not got them yet:
'GDI+ Custom Controls with Visual C# 2005' by Tiberiu Radu, Iulian Serban, Dragos Brezoi, Adam Ward
'Pro .NET 2.0 Windows Forms and Custom Controls in C#' by Matthew MacDonald
'Windows Forms 2.0 Programming' by Chris Sells, Michael Weinhardt
Anyone have any experience with these books, or maybe could recommend something similar?
Thanks for your time, in advance! =)
|
|
|
|
|
In regards to measuring your text, you could just add a constant value to the total width assuming the size of the button does not change.
Just because we can; does not mean we should.
|
|
|
|
|
hpjchobbes wrote: This works, except for one problem, it does not include the width for the drop down button on the DateTimePicker contro
I am having success using SystemInformation.VerticalScrollBarWidth for the dropdown button width in my experiments.
led mike
|
|
|
|
|
I am creating an IE toolbar and I need it to launch a javascript page when the toolbar button is clicked.
Below is the code that I am using and getting errors.
private void btnToolStrip_Click(object sender, EventArgs e)
{
// Launches the post window
Page.ClientScript.RegisterStartupScript(this.GetType(), "CustomButton", "<script language=JavaScript> window.open('http://hvkclncswsvr10.gign.kcl.mtec.mds.lmco.com/tachyon_proj/post/?item='" + content.document.location.href + "'&title='" + encodeURIComponent(document.title) + "','Tachyon Post','width=850,height=500,resizable=yes');</script>");
}
When i build this i get errors on the name Page, content, encodeURIComponent, and document. Is it possible to run the JS this way from a ToolStripButton clcik event or do I need to do it another way?
<div class="ForumMod">modified on Wednesday, July 2, 2008 11:48 AM</div>
|
|
|
|
|
You probably want to ask in the asp.net forum
|
|
|
|
|
OK... I'll Try that...
Thanks
|
|
|
|
|
FSW dont raise event when i set its filter to custom extension, like if i set it to "*.abcd" then no event will raise but if i set it to other known extensions like "*.txt" or something else it works, any idea how to solve ?
my second question is that how it works, is it works like timer mean it keep refresh after some inbuilt specified time or any window function send info to it when a file created and it raises event ?
thanks
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
FSW monitors a directory for file creation, modification, deletion and renaming. The custom expression is to monitor only those file types that match that expression.
This example monitors only the directory where dir == the directory to monitor and only raise an event on file types of txt.
fileWatcher = new FileSystemWatcher(dir, "*.txt");
fileWatcher.EnableRaisingEvents = false;
fileWatcher.IncludeSubdirectories = false;
fileWatcher.NotifyFilter = NotifyFilters.FileName;
fileWatcher.Created += new FileSystemEventHandler(fileWatcher_Created);
Set fileWatcher.EnableRaisingEvents = true to enable the monitoring. To stop monitoring set the value to false.
http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.aspx[^]
Just because we can; does not mean we should.
|
|
|
|
|
i know that, i think you didnt read my problem properly i said it dont raise any event when i set custom filter, for example
if i write
FSW.Filter = "*.abcd"; // wont work, if i create any file with extension abcd
but if i write
FSW.Filter = **.txt"; // will work, if i create any file with extension txt
EDITED :
SOLVED
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Not sure where your having problems. I did this test and had no problems getting the notifications.
Sorry
private void Form1_Load(object sender, EventArgs e)
{
fileSystemWatcher1 = new System.IO.FileSystemWatcher(@"C:\");
fileSystemWatcher1.IncludeSubdirectories = false;
fileSystemWatcher1.NotifyFilter = NotifyFilters.FileName;
fileSystemWatcher1.Filter = "*.abcd";
fileSystemWatcher1.Created += new System.IO.FileSystemEventHandler(fileSystemWatcher1_Created);
fileSystemWatcher1.Changed += new System.IO.FileSystemEventHandler(fileSystemWatcher1_Changed);
fileSystemWatcher1.Renamed += new RenamedEventHandler(fileSystemWatcher1_Renamed);
fileSystemWatcher1.Deleted += new FileSystemEventHandler(fileSystemWatcher1_Deleted);
fileSystemWatcher1.EnableRaisingEvents = true;
File.Delete(@"C:\test.abcd");
StreamWriter sw = new StreamWriter(@"C:\test.abcd",true);
sw.WriteLine("test");
sw.Close();
sw.Dispose();
}
void fileSystemWatcher1_Deleted(object sender, FileSystemEventArgs e)
{
MessageBox.Show("File Deleted " + e.FullPath.ToString());
}
void fileSystemWatcher1_Renamed(object sender, RenamedEventArgs e)
{
MessageBox.Show("File Renamed " + e.FullPath.ToString());
}
void fileSystemWatcher1_Changed(object sender, System.IO.FileSystemEventArgs e)
{
MessageBox.Show("File Changed " + e.FullPath.ToString());
}
void fileSystemWatcher1_Created(object sender, System.IO.FileSystemEventArgs e)
{
MessageBox.Show("File Created " + e.FullPath.ToString());
}
Just because we can; does not mean we should.
|
|
|
|
|
thanks for reply but as i said in previous post that problem solved because i had an error in that extension
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
In My scenario, i will be sending an automated mails to the employess.
in that mail, i will be providing a hyperlink which points to a outlook addin which inturn opens a windows form window.
How can i automate the above task. like clicking on the hyperlink, i should be able to load the addin as well..
Can you help me in this regard??
|
|
|
|