|
first check if the file already exists or not
File.Exists(path2)
if yes then prompt message if user reply yes
then remove it first and then copy
Best Regards,
Chetan Patel
|
|
|
|
|
Are both filepath and destinationpath parameters a fully qualified file name or is destinationpath just the target folder? File.Copy can only copy files, so both parameters need to be fully qualified file names.
Look at the File.Copy Method (String, String)[^] docs, specifically at the IOException information listed under the Exceptions section.
You will get this exception if an I/O error occurs (unlikely) or the destination already exists, which is what is happening here. You can either do a File.Exists test before the copy and only copy if the file doesn't exist, or use the File.Copy(String, String, Boolean) form and pass in true as the boolean value to indicate that you want to overwrite the file.
|
|
|
|
|
Hi Friends,
I have a DataGridView control with a DataGridViewComboBox column with some items in the combo box.
My requirement is to open a new form upon selecting a particluar item in the combo box column of a row.
Which event of the DataGridView is to be captured to get the item selected in the combo box immediately up on selecting the item?
Thanks in advance for some help.
Subrahmanyam K
|
|
|
|
|
hello
can anybody give me an idea how to create an undo function for my application control
plz regards
dghdfghdfghdfghdgh
|
|
|
|
|
If your control is already written, you've got a lot of work ahead of you. Adding an "Undo" feature isn't just a couple of lines of code. You've got to plan for this before you write a single line of code because it completely changes how your control works internally.
Google for "Command pattern" and start reading...
|
|
|
|
|
Take a quick look at this months voting articles and look for the generic Undo. That's a good starting point - although as Dave said, you really should have planned for this from the start.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Pete O'Hanlon wrote: Take a quick look at this months voting articles and look for the generic Undo
Dang it, Pete, you beat me to it. A nice article, I may add
"Try asking what you want to know, rather than asking a question whose answer you know." - Christian Graus
|
|
|
|
|
Hello,
I've never read any articles on what are best practices on designing WinForms (or desktop applications in general) that make heavy use of a database, specifically when the database is in the same computer as the application, does anyone have any good links?
Anyway, my main question is about connection opening/closing, is it a good idea to open and close a connection every time you query the database? or is it better to open the connection when the form loads and then close it when the application closes?
What if the database is in a different computer? in my short experience it seems like only the first time you open the connection it can take some time, after that it seems to be instantaneous.
Any tips or recommendation in this area would be greatly appreciated.
|
|
|
|
|
Marcosm64 wrote: is it better to open the connection when the form loads and then close it when the application closes?
No, it isn't you should keep your connection open as short as possible but if you know that you have to execute several commands in a short period of time then you shouldn't open and close every time you execute a command.
|
|
|
|
|
|
I have a couple of problems with toolstrip tool tips I'm hoping someone can shed some light on.
First of all is the most annoying, and this occurs when I have a maximized window with a status strip and some toolstrip contrls on the status strip that have tool tips. When the user hovers over one of these controls, the tool tip (which would normally show up beneath the cursor) appears directly UNDER the cursor (because presumably it doesn't want to show over the task bar), however for some reason this creates a ridiculous looping effect where the tooltip appearing results in the mouse no longer being "over" the toolstrip item which hides the tooltip, which causes the mouse to once again appear over the item, which shows the tooltip, etc. etc. etc. It's humorous to watch.
The second is more important as it would provide an enhanced user experience if I can solve it, and that is that I need access to a toolstrip item (specifically toolstripsplitbutton)'s ToolTip, or at the very least the ability to explicitly hide it or ideally refresh it because I have a pair of back/forward buttons that I change the ToolTipText of to reflect the target of the button. For some reason, the tool tip is not updated immediately to reflect this, if it happens to be already visible.
If anyone has any knowledge of how to get more control over a ToolStrip's ToolTips please tell me.
Logan
|
|
|
|
|
Hi All,
i want to get the folder path which the user has selected in the explorer....
urgent please................
If U Get Errors U Will Learn
If U Don't Get Errors U Have Learnt
|
|
|
|
|
With the over file dialog? if so then it is like this in C#:
OpenFileDialog ofd = new OpenFileDialog();
ofd.Title = "Open Text File";
ofd.InitialDirectory = Application.StartupPath;
ofd.Filter = "Text files (*.txt)|*.txt";
ofd.FilterIndex = 0;
if (ofd.ShowDialog() == DialogResult.OK)
{
MessageBox.Show(ofd.FileName,"File picked:");
}
|
|
|
|
|
Hi all,
I would like to have a dropdown control column in my windows form datagrid,
can anyone please help me with this??
I am using .NET 1.1 so no .NET 2 control info plz
|
|
|
|
|
Examine the e.Node property
|
|
|
|
|
A TreeView has several events; some of them have a TreeViewCancelEventArgs parameter,
and that one has a Node member. MSDN will gladly concretize all of this.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
You know that the first sign of madness is talking to yourself. Obviously, the second sign is getting an answer.;P
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
More and more the challenge on these discussion boards is to come up with answers that
make kind of sense no matter what happens to the original question...
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Hi all,
I use a 3rd party component in my winform, and I try to show the same smart tag menu I use in design time(visual studio 2005) in run-time.
So the end-users can customize the component. (change Text, add Image...)
Is there a way to enable the smart tag menu at run-time ?
perhaps should I use reflection
Thanks in advance
kam
|
|
|
|
|
no, you're asking for VS2005 to exist inside your app. You can write your own code, or you could indeed write some code that uses reflection to find and expose properties. But, you cannot get the VS IDE outside of VS.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I am creating an application for a Cinema Complex which has 4 cinemas running movies concurrently so far I'm trying to find some examples on the net but have not come up with any. Would anyone please help me to see any example.
|
|
|
|
|
Why are you finding the example for that?
What you should do is that ~
- find out what your customers wants (collecting the requirement)
- design the application based on requirement.
- create the demo and show it to customer.. (get it approved)
- then, start the coding...
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
|
|
|
|
|
What does this application do ? You've given us no idea. Also, unless this is homework, you want to ask the client what they want, as someone else said. Nothing we say means much, we don't run cinemas, and we sure don't run THAT cinema
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I think he is looking for a ready-to-run-after-a-download from an opensource website.
|
|
|
|
|
It has been quite a while. I have a task to identify a calling Windows' batch script's name and its location. Basically, the batch script calls/spawns my C++ executable as a parent process and I failed to identify the parent. I can identify a number of different calling processes using NtQueryInformationProcess(), but failed to do so to the batch script. The main reason is that the batch process is shown as cmd.exe not a real script name. Any deal?
Thanks a lot for the help.
|
|
|
|