|
Colin Angus Mackay wrote: If you want to ignore the extension on a filename then ignore everything after the last dot. If that does not answer your questions then please clarify it.
exactly can u plz send me some code how to ignore the extension after the dot
regards
sunilwise
|
|
|
|
|
sunilwise wrote: can u plz send me some code how to ignore the extension after the dot
First, please write properly - I have no patience for people who contract word such as "you" in to "u" and "please" in to "plz". The English language has a perfectly acceptable mechanism for contracting words by the use of an apostrophe to stand in for missing letters. If you absolutely must use abbreviations please use ones that are understandable to all. Not everyone on this forum speaks English as their first language. They will have difficulty reading badly written text.
In answer to your question look into the string class and look for things to get you the LastIndexOf[^] in order to tell you where the dot is and Substring[^] in order to get a new string without the extension.
Alternatively, classes such as FileInfo and Path also have methods for dealing with bits of file names.
|
|
|
|
|
Colin Angus Mackay wrote: Not everyone on this forum speaks English as their first language. They will have difficulty reading badly written text.
Good point.
"If you divide your text into sentences, it might be possible to understand what you are trying to say." - Guffa
|
|
|
|
|
protected void btnSubmit_Click(object sender, EventArgs e)
{
try
{
FileInfo TheFile = new FileInfo(MapPath(".") + "\\" + txtOldFile.Text);
if (TheFile.Exists)
{
File.Move(MapPath(".") + "\\" + txtOldFile.Text,MapPath(".") + "\\" + txtNewFile.Text);
}
the above is my code for renaming the file in my application its working fine, but what i want is i want to keep my original file as it is and create another file with same content in it with different name
valid suggestions are appriciated
thanks in advance
regards
sunilwise
|
|
|
|
|
File.Copy
Experience is the sum of all the mistakes you have done.
|
|
|
|
|
thanks for reply its working
|
|
|
|
|
Hello,
I am using MySql as my database. I can fill individual tables, however when I query to select from 2 different tables and do an add watch on the dataset the count for those 2 tables is 0.
Everything runs without errors. However, when I check count property for the table in the add watch it gives an zero.
However, if I write the query like this: "SELECT * FROM Beverage"
and fill using this da.Fill(DS.Beverage); Then the count display the correct number of rows.
Can anyone explain this?
Many thanks,
My code for filling
try<br />
{<br />
this.OpenConnection();<br />
<br />
RestaurantDataSet ds = new RestaurantDataSet();<br />
MySqlDataAdapter da = new MySqlDataAdapter();<br />
MySqlCommand cmd = new MySqlCommand();<br />
<br />
cmd.Connection = cnn;<br />
cmd.CommandType = CommandType.Text;<br />
cmd.CommandText = "SELECT maincourse.MainCourseID, beverage.BeverageID FROM maincourse, beverage";<br />
<br />
da.SelectCommand = cmd;<br />
da.Fill(ds);<br />
<br />
return ds; <br />
}<br />
catch (Exception ex)<br />
{<br />
Console.WriteLine(ex.Message);<br />
return null;<br />
}
|
|
|
|
|
steve_rm wrote: cmd.Connection = cnn;
Where is cnn ? Is it a global? I am assuming the connection is opened and cnn is set when you execute this.OpenConnection();
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hello,
Problem solved. The query was pulling 2 tables out of the database and which will create a new data table.
Steve
|
|
|
|
|
Cool deal that you got it solved
"The early bird may get the worm, but the second mouse gets the cheese" - anonymous, found in Uncle John's Bathroom Reader
|
|
|
|
|
Hi,
My aim is to print the windows form dynamically .
The code which i have implemented for creating a bmp.file of the form is
/*
Bitmap bit = new Bitmap(this.Width, this.Height);
this.DrawToBitmap(bit, new Rectangle(0, 0, this.Width, this.Height));
bit.Save(@"c:\new.bmp", System.Drawing.Imaging.ImageFormat.Bmp); */
So the image is getting stored now i want to print it on a single button click if possible before that a preview screen.. if anyone knows how to complete this task or any ideas please let me know
regards
sindhu tiwari
Alwasys Innovative
|
|
|
|
|
Try this...
(When PrintForm() is called, a printer settings dialog will popup. If OK is pressed, the printer will start printing... when the printer is ready to print it will call pdoc_PrintPge where you can alter its graphics object (e.Graphics ).
(You will need to set e.HasMorePages to false to print just one page).
PrintDocument pdoc;
PrinterSettings pset;
public void PrintForm()
{
pdoc = new PrintDocument();
pset = new PrinterSettings();
PrintDialog pdia = new PrintDialog();
if (pdia.ShowDialog() == DialogResult.OK)
{
pset = pdia.PrinterSettings;
pdoc.PrinterSettings = pset;
pdoc.PrintPage += new PrintPageEventHandler(pdoc_PrintPage);
pdoc.Print();
}
}
private void pdoc_PrintPage(object sender, PrintPageEventArgs e)
{
e.Graphics.DrawImage(bmp, new Point(0, 0));
e.HasMorePages = false;
}
I hope this helps.
Matthew Butler
|
|
|
|
|
hi
i create a queue and service in my sql server 2005 by this code :
create queue myNotificationQueue
create service myService on queue myNotificationQueue
in my csharp code i wrote this code :
class Program
{
string connstring = null;
SqlConnection conn = null;
SqlDataReader rdr = null;
static void Main(string[] args)
{
Program c = new Program();
c.connstring = @"Data Source=MYLAPTOP\SQLLAPTOP;Initial Catalog=pubs;persist Security Info=True;User ID=sa;password=1";
c.conn = new SqlConnection(c.connstring);
c.DoWork();
Console.ReadLine();
}
private void DoWork()
{
conn.Open();
rdr = GetJobs();
if (rdr != null)
{
rdr.Close();
WaitForChanges();
}
conn.Dispose();
}
public SqlDataReader GetJobs()
{
using (SqlCommand cmd = new SqlCommand("Select job_id, job_desc from dbo.jobs", conn))
{
try
{
//cmd.Parameters.AddWithValue("@id", JobId);
SqlNotificationRequest not = new SqlNotificationRequest();
not.UserData = Guid.NewGuid().ToString();
// this must be a service named MyService in the pubs database
// associated with a queue called notificationqueue (see below)
// service must go by QueryNotifications contract
not.Options = "service=myService;local database=pubs";
not.Timeout = 0;
// hook up the notification request
cmd.Notification = not;
rdr = cmd.ExecuteReader();
while (rdr.Read())
Console.WriteLine(rdr[0]);
rdr.Close();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
return rdr;
}
}
public void WaitForChanges()
{
// wait for notification to appear on the queue
// then read it yourself
using (SqlCommand cmd = new SqlCommand("WAITFOR (Receive convert(xml,message_body) from myNotificationQueue)", conn))
{
cmd.CommandTimeout = 0;
object o = cmd.ExecuteScalar();
// process the notification message however you like
Console.WriteLine(o);
}
}
}
but when i compile it, and change jobs table, nothing occured. where does my problem ?
& How to solve my problem ?
thanks
|
|
|
|
|
WRONG FORUM...............................................................................................
its me sid
|
|
|
|
|
|
What is the core problem ? Working with delegates ? There are articles on CP about delegates, it's pretty easy. A delegate is a method which, when called, will call any number of methods that have the same signature, and have been assigned to that delegate. Events are delegates.
The code sample you linked to does not read fingerprints ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hey Christian,
No my core problem is reading the fingerPrint reader. I mentioned the delegates because I'm reading the book Visual C# 2005 step by step and that's where i am reading now.
Basically all i need to do is to grant access to my application using the finger prints. For that i think i need to read the finger print reader store the finger prints on the database and then whenever they need to run the application they can do so.
But I have no idea how to capture the images and as matter of fact i don't what to do...
The code sample from the link reads finger prints but first is in Visual Basic, which i can read but not port to C#, and second it is not complete.
What should i do?
I have until November 15th to finish this project, and there are so many small and security details to code that 5 days looks so small, if not i won't graduate from college...
Can u help me?
Regards
Luis E Tineo S
|
|
|
|
|
There are online tools to convert VB.NET snippets to C#.
How is it that you're 'not a programmer', but you need to finish a programming assignment to pass college ?
_GrFingerX.CapRawImageToHandle(raw.img, raw.width, raw.height, hdc, handle) get you the bitmap. What sort of database do you want to store it to ? Does the SDK offer methods to compare fingerprints ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Christian Graus wrote: How is it that you're 'not a programmer', but you need to finish a programming assignment to pass college ?
Hmmmmmmmm.
"If you divide your text into sentences, it might be possible to understand what you are trying to say." - Guffa
|
|
|
|
|
It is a long story, the thing is that i study telecommunications engineering, which is a combination of Programming and Electronics engineerings. I am good at electronics and PC hardware plus network stuff but when it comes down to programming i know nothing but what i have learnt recently in Visual C#, i used to use ANSI C but for console applications only... php for websites and databases data flow control... and there it goes my programming life. In my college/University, I am not from the states and i don't live in the states so it is hard for me to tell which one I am studying in, we need to do a big final project to show them what we have learnt through the years.
Thanks to this website examples, some online books, people like you and hard work i have been able to learn faster than i thought and really good... however i am feeling the pressure and the fatigue so i am not quite sure of what should i do with the fingerprint reader because there a new stuff showing up...
If needed i can show you the example of the SDK from grFinger to see what i should do or how i should do it....
Thank you so much for you interest on helping me out!!!
Best regards,
Luis E Tineo S
|
|
|
|
|
kingletas wrote:
Thanks to this website examples
This site is just plain awesome. No question about it
kingletas wrote: If needed i can show you the example of the SDK from grFinger
You should write an article about it. I am sure alot of people would maybe find it interesting.
"The early bird may get the worm, but the second mouse gets the cheese" - anonymous, found in Uncle John's Bathroom Reader
|
|
|
|
|
Christian Graus wrote: A delegate is a method which, when called, will call any number of methods that have the same signature, and have been assigned to that delegate.
No, that's an event. A delegate is a single method reference.
Christian Graus wrote: Events are delegates.
No, events uses delegates.
Experience is the sum of all the mistakes you have done.
|
|
|
|
|
Hello,
I am working on C# project 2.0. I have browser control and I need to create favorites and saving favorites URL’s in text files on a local machine assuming the file is in same directory where the project is located. Can anyone please help me with this.
p.s. Please show some codes if you can. Thanks a lot in advance. I need it for my job.
A.Asif
|
|
|
|
|
What have you done so far and where are you stuck?
|
|
|
|
|
Hello,
I haven't done anything. I am totally lost. I have never done anything like this before. Please help..I need it for my job.
Thanks a lot.
A.Asif
|
|
|
|