|
a simple function as such should do the trick.
void MoveMe(string filename)
{
int x = 1;
string newfile = filename;
while(System.IO.File.Exists(newfile) == true)
{
String[] tmp = filename.Split(Convert.ToChar("."));
newfile = tmp[0] + x + "." + tmp[1];
x++;
}
System.IO.File.Move(filename, newfile);
}
-- modified at 13:45 Monday 12th September, 2005
|
|
|
|
|
do the variables filename and newfile includes the directory?
|
|
|
|
|
in this case, yes. The file name is split at the "." in the filename.
So if filename = C:\Autoexec.bat then newfile = c:\Autoexec1.bat
Because of design, if a file name consists of more than one period, you will receive unexpected results.
|
|
|
|
|
Hello all
I am starting a mailer application project in c# using Visual Studio .Net. As I need to learn more about the process of sending emails (e.g email message structures, SMTP Protocol etc.) , I would appreciate it if you could send a few links to relevant reading material and examples.
And equally important - I need to know which classes and assemblies deal with sending email messages (I saw something about microsoft.uddi.dll in the Visual Studio help).
Will appreciate any help,
Thanks,
Gal
|
|
|
|
|
|
That's great, it will really help me get started.
Thanks a lot.
Gal
|
|
|
|
|
Hi,
I would like to build an application for both smartphones and pdas running windows mobile 2003 or 2005. what is the best practice to develop such application?
regards,
rnv
|
|
|
|
|
|
In the C# books I've read, drawing objects such as pens, brushes, etc are usually created in a using declaration in OnPaint(). I don't see anything wrong with this as it seems to be more resource friendly but I've heard others say these objects should be cached, such as storing them as instance fields. Are there any guidelines for going one way versus the other?
|
|
|
|
|
The only guidelines I can suggest are:
1) How many times a second are you going to repaint your form? If your writting an analog clock that repaints itself every 50 milliseconds, you'll want to create your pens and brushes once and cache them so you're not creating and destroying them a couple hundreds times per second. If you only repaint the form when Windows tell you to, then you could probably get away with creating and destorying your pens and stuff on demand.
2) If you're painting alot of static stuff. In the clock example, the clock face and hands don't change between any repaints. Just the positions of certain items change. In this case you could get away with caching your drawing objects. If you're painting dynamic data that frequently changes the colors of what your drawing between repaints, then you'll have to create and destroy your drawing objects on demand.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks Dave,
Those are some good examples of when caching might be useful.
|
|
|
|
|
Hello everyone,
I am working on a data acquisition project. Every 1/5 second I read data from a device. It's delivered in a two dimesional array. I want to put samples in a file every 2 seconds. Is there a way to add a twodimensional to another twodimensional array?
I did only find the CopyTo, but it only supports onedimensional arrays.
Software: Visual Studio 2003 C#
Thanks in advance,
Souza
|
|
|
|
|
Is it a 2D array or a jagged array ? If a jagged array, I think you add them one single dimensions array at a time.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hello Christian,
You are right about the jagged array. But I get the smples in a 2d array. And there is nothing there can be changed about that. Thanks for your post anyway.
Souza
|
|
|
|
|
How to get acces to each element of the array, which is a member of the class, on which we are using reflection?
|
|
|
|
|
so in example:
Class Test
{
public int[,] a = new int[4,4];
void fun()
{
Type ClassType = typeof(Test);
FieldInfo[] Values = ClassType.GetFields();
foreach(FieldInfo val in Values)
{
???
}
}
}
|
|
|
|
|
|
I have to make a de/serialization similar to XML, but my own
Nevertheless, there is one more problem. During reflection I may have some different arrays of different types (not only int32, but also double, char, etc).
That`s why i cannot declare
int[,] reflecteda = aField.GetValue(this) as int[,];
The information about type of the array is hidden in aField.FieldType which gives eg. "System.Int32[,]". How to declare the needed array, which type is hiden there?
tnx in advance
|
|
|
|
|
Dear All,
I am trying to call a function from an Intel dll that's originally written in C/C++.
It's original prototype is :
HIGHGUI_API IplImage* cvvLoadImage( const char* filename );
I have marshalled it as :
[DllImport("highgui.dll")]
[return : MarshalAs(UnmanagedType.Struct)]
unsafe public static extern IplImage * cvvLoadImage(string filename);
when I try to run it ,I get the following error.Does anyone know how can I fix that?
Error: Cannot take the address or size of a variable of a managed type ('IplImage')
I have marshaled the originally struct IplImage into :
[StructLayout(LayoutKind.Sequential)]
unsafe public struct IplImage
{
....
};
Best Regards,
E.A.
|
|
|
|
|
i'm working in aproject doing something loke massenger of msn and i wanna form popup to the user when another message to the user
i do the code put the form show in normal way i wanna it
appear sequencly
|
|
|
|
|
Hello,
I have a dataset, and I want to sum up the values from certain column to a certain column (for example, rom comumn 3 to column 7).
So, is there a way of getting the index of the column?
Sort of row[0][column].Index, or something like that?
Thank you
|
|
|
|
|
You could do something of the following....
int[] cols = {2,3,5};
int total = 0;
for(int x=0;x<=cols.length -1;x++)
total += row[0][cols[x]];
above code is untested!
|
|
|
|
|
//this is for each row
foreach ( DataRow row in this.dataTable1.Rows )
{
int sum = Convert.ToInt32(row[3]) + Convert.ToInt32(row[7]);
}
//if you know the row index then use this
int sum = this.dataTable1.Rows[1][3] + this.dataTable1.Rows[1][7];
|
|
|
|
|
Try it with this function:
dataset.Tables["TableName"].Columns.IndexOf("ColumnName");
|
|
|
|
|
Hi Please let me know how to open uneditable word document in windows form C#.net.
It just like preview of document in windows form.
Thanks
|
|
|
|