|
|
Hello leppie,
Thanks for your reply.
I tried this:
foreach(AssemblyVersionAttribute avat in Assembly.GetExecutingAssembly().
GetCustomAttributes(typeof(AssemblyVersionAttribute), true))
{
MessageBox.Show(avat.Version);
break;
}
and it doesn't work. The loop doesn't execute, as if it couldn't find any attributes of that type.
I have this on another source file in the same project (and it is displayed when I click Properties on my .exe in Windows Explorer):
[assembly: AssemblyVersion("1.0.4287.0")]
Any ideas?
-- LuisR
___________
Luis Alonso Ramos
Chihuahua, Mexico
www.luisalonsoramos.com
|
|
|
|
|
I just put this piece of code in my About box to get the latest version..
this.lblVersion.Text = "Version "
+ (System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.Major.ToString())
+ "."
+ (System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.Minor.ToString())
+ "."
+ (System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.Build.ToString())
+ "."
+ (System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.Revision.ToString());
|
|
|
|
|
|
Hi,
is it possible to open a window containing all the files in a directory and letting the user choose a file to be renamed? I've written the code to open the window and display the files and I'm fairly sure the next step will involve the File.Copy or File.Move method but I can't work out the next few lines of code.
The selected file will always be renamed under the same term (ie somefile.txt) as there are more processes to be carried out on the file before it is finished with. The user can then select the next file in the list to be renamed and so the process continues ad nauseum (until I write the code to loop it. Rookies eh?)
The code thus far looks like the following, (sorry, I know you all know what this looks like, just thought it was better to include it than not)
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "CET File (*.cet)|*.cet|PET File (*.pet)|*.pet|All files|*.*";
sfd.Title = "Save File as";
sfd.FileName = @"c:\temp\thisfile.txt";
if(sfd.ShowDialog() == DialogResult.OK)
{
}
Like I say, I'm almost positive there is some clever use of the File.Move or File.Copy method to be invoked here. I got it to work when I coded in a specifically chosen filename but that obviously only works on one pass. I need it to be user-selected. Please can someone out there help?
Thank you in advance
Scotty
|
|
|
|
|
how about:
if(sfd.ShowDialog() == DialogResult.OK)
{
System.IO.File.Copy(myfile,sfd.FileName,true);
}
where myfile is a string with the original file name, and true alows overwriting? or have i misunderstood your question?
there are no facts, only interpretations
|
|
|
|
|
Hi,
yeah, that was it. My solution worked also when I realised I had declared a couple of variables to hold path names outside of the block of code I was working on. Once I put them in the right place, it all clicked together.
Thanks for replying anyhoo, much appreciated.
|
|
|
|
|
I have a problem, if someone will help i'm be very happy for it.
I want to read a binary file into a struct. Please help.
public sealed class InfoHeader
{
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi)]
private struct Info
{
public UInt32 version;
[MarshalAs(UnmanagedType.ByValArray, SizeConst=20)]
public Byte[] tapenr;
[MarshalAs(UnmanagedType.ByValArray, SizeConst=10)]
public Byte[] client0;
};
private Info info;
public void Read(BinaryReader reader)
{
int length = (int)Marshal.SizeOf(typeof(Header));
byte [] buffer = reader.ReadBytes(length);
// What is the next step get the buffer into the struct.
}
public void Write(BinaryWriter writer) ...
}
I don´t want to do this for every property.
this.version = reader.ReadUInt32();
Gywox
|
|
|
|
|
The only way I know is to copy the binary data into unmanaged memory, and then copy it back:
//get unmanaged memory
IntPtr pointer = Marshal.AllocHGlobal(length);
//copy the bytes into unmanagted memory
Marshal.Copy(buffer, 0, pointer, length);
//copy the bytes back into the structure
Info info = (Info)Marshal.PtrToStructure(pointer, typeof(Info));
|
|
|
|
|
When I return an object using get property how can I be sure
that it will not be changed outside (like const in C++)?
For example:
class A
{
private Hashtable ht;
public Hashtable Table
{
get
{
return ht;
}
}
}
|
|
|
|
|
You can't. That is one of very few things I dislike about C#. You can't reassign the Hashtable object itself, but you can still change its contents.
Do you want to know more?
Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.
|
|
|
|
|
You can't protect the object itself, but you can return a copy:
<br />
private Something s;<br />
public Something S{<br />
get{ return s.Clone(); }<br />
}<br />
For a Hashtable, you have to copy the content yourself. Hashtable.Clone() return only a flat copy.
<br />
public Hashtable Table{<br />
get{<br />
Hashtable htCopy = new Hashtable(ht.Count);<br />
foreach(object key in ht.Keys){<br />
htCopy.add(key, ht[key].Clone());<br />
}<br />
return htCopy;<br />
}<br />
|
|
|
|
|
Hello,
I have two tables From one table i want to retrieve two values and from the other also two values. And the condition is when the one value of the first table has a certain value. (In my case EngineerUserId). The problem is with my current statement the rows will be displayed two times.
Have anybody know an idea?
My current statement looks as follows:
"SELECT p.JobId, p.Priority, c.CompanyName, c.ContactLName FROM JobDescription p INNER JOIN Client c ON p.EngineerUserId = ? ORDER BY p.Priority";
thx
patrick
|
|
|
|
|
pat270881 wrote:
SELECT p.JobId, p.Priority, c.CompanyName, c.ContactLName FROM JobDescription p INNER JOIN Client c ON p.EngineerUserId = ? ORDER BY p.Priority
Do you mean the ? as a parameter placeholder of that you don't know what you should put there.
If it is the latter then:
INNER JOIN Client p.EngineerUserId = c.EquivalentColumnNameInClientTable
If you need to add a condition you should add a WHERE clause before the ORDER BY
so you might get something like this (I've assumed that the client table has a column called EngineerUserId, if it doesn't you need to replace it with the column that does contain that value)
SELECT p.JobId, p.Priority, c.CompanyName, c.ContactLName
FROM JobDescription p
INNER JOIN Client c ON p.EngineerUserId = c.EngineerUserId
WHERE p.EngineerUserId = ?
ORDER BY p.Priority
Oh, and by the way, this should really have gone in the SQL Forum[^]
Do you want to know more?
Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.
|
|
|
|
|
Okay, thank you, now it works!
Thx
patrick
|
|
|
|
|
Hello,
Is it possible to set the Background of a certain Tab Pane of the Tab Control? - And where does appear the icon which i can set in the Designer in VS.NET in a Tab Control?
thx
mathon
|
|
|
|
|
It concerns a Smart Device Application.
|
|
|
|
|
Hello,
In addition to that how can I find out what tab pane of the tab control is currently selected?
Regards
patrick
|
|
|
|
|
pat270881 wrote:
In addition to that how can I find out what tab pane of the tab control is currently selected?
its a good idea to check the object browser before posting, in this case the TabControl exposes a public property named "SelectedTab"
|
|
|
|
|
But in the Object Browser is not quoted which event occurs when I go from one tab pane to another tab pane..?? - and I also did not find a background property for the tab pane?
patrick
|
|
|
|
|
pat270881 wrote:
But in the Object Browser is not quoted which event occurs when I go from one tab pane to another tab pane..??
Yes, there is. It's called SelectedIndexChanged .
pat270881 wrote:
and I also did not find a background property for the tab pane?
That's because there isn't one. Changing the background color of the Tab pane isn't supported by the default implementation. You'll have to owner draw the TabControl in order to change the background color of a single pane.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Okay, i have built a wonderful, slick application that is a deep, convoluted call-tracking system of sorts. There is an approval process built in, that uses email addresses to identify the approvers.
the problem is, there are required approvers that exist in multiple places, resulting in some people being listed more than once.
Essentially, here is what i have been running into. the names are strung together like this:
user1*user2*user3*user4
except sometines, you end up with
user1*user2*user3*user4*user2*user1
what i have been killing myself over, is trying to make a quick function that would look at this list, say "we already have user's 1 and 2, so only list them once".
I spent 4 hours on this yesterday, and ended up with an extremely complicated way to turn "user1*user2*user3*user4*user2*user1"
into
user1
user2
user3
user4
user2
user1
which, of course, can be done with 3 or 4 lines of code, not the 50 something i made yesterday. any ideas?
Yes, I am the highly suggestable type.
|
|
|
|
|
You mean something like:
String strUserList = "user1*user2*user3*user4*user2*user1";
char[] sep = {'*'};
Array a = strUserList.Split(sep);
(written without a compiler, so might not be syntactially perfect..)
--
Help me! I'm turning into a grapefruit!
Phoenix Paint - back from DPaint's ashes!
|
|
|
|
|
Pretty much how i split it up, i just now need to squish that array so that there is only 1 of each item.
Yes, I am the highly suggestable type.
|
|
|
|
|
ArrayList?
ArrayList list = new ArrayList();
foreach(string str in mySplitArray)
{
if(!list.contains(str))
list.add(str);
}
|
|
|
|