Click here to Skip to main content
15,881,204 members
Home / Discussions / C#
   

C#

 
AnswerRe: Why does this code hang? (async) Pin
Eddy Vluggen2-Nov-12 2:00
professionalEddy Vluggen2-Nov-12 2:00 
QuestionWCF Windows Service with ASP.net Application authentication problem... Pin
JD861-Nov-12 11:37
JD861-Nov-12 11:37 
AnswerRe: WCF Windows Service with ASP.net Application authentication problem... Pin
JD861-Nov-12 11:48
JD861-Nov-12 11:48 
QuestionService Installer not generating the service exe file Pin
JD861-Nov-12 5:10
JD861-Nov-12 5:10 
AnswerRe: Service Installer not generating the service exe file Pin
JD861-Nov-12 5:18
JD861-Nov-12 5:18 
AnswerRe: Service Installer not generating the service exe file Pin
CafedeJamaica1-Nov-12 11:05
professionalCafedeJamaica1-Nov-12 11:05 
GeneralRe: Service Installer not generating the service exe file Pin
JD861-Nov-12 11:13
JD861-Nov-12 11:13 
QuestionBackup/Restore - SQL Compact Edition Pin
saturnuk31-Oct-12 22:47
saturnuk31-Oct-12 22:47 
Hi Guys,

I'm not English so I'll try to explain my problems as simple as possible
I've been trying to backup/restore SQLce database for one of my latest applications.
This is how my code looks like:

This button opens location in which user can save .sdf (backup):
C#
private void button2_Click(object sender, EventArgs e)
        {
            DialogResult ofd = folderBrowserDialog1.ShowDialog();

            if (ofd == DialogResult.OK)
            {
                string backupPath = folderBrowserDialog1.SelectedPath;
                textBox4.Text = backupPath;
            }
        }


... then file is being saved in chosen location (backup):
C#
private void button4_Click(object sender, EventArgs e)
        {
            string fileName = "Database.sdf";
            string sourcePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            string backupPath = textBox4.Text;

            string sourceFile = System.IO.Path.Combine(sourcePath, fileName);
            string destFile = System.IO.Path.Combine(backupPath, fileName);

            System.IO.File.Copy(sourceFile, destFile, true);
        }


To restore database user opens location with .sdf file:
C#
DialogResult ofd = folderBrowserDialog1.ShowDialog();

           if (ofd == DialogResult.OK)
           {
               string backupPath = folderBrowserDialog1.SelectedPath;
               textBox5.Text = backupPath;
           }
       }


...and restore file using this code:
C#
try
            {
                string fileName = "Database.sdf";
                string sourcePath = textBox5.Text;
                string restorePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                //string restorePath = @"";

                string sourceFile = System.IO.Path.Combine(sourcePath, fileName);
                string destFile = System.IO.Path.Combine(restorePath, fileName);

                System.IO.File.Copy(sourceFile, destFile, true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }


I've checked all of this locally I mean after debugging and works perfectly.
When my application is published and than installed this code doesn't work. Throws an error 'Could not find file C:\Users\Lion\AppData\Local\Apps\2.0\J98YQDCL.P3L\3TX9ONZ9.XO3D\Database.sdf'

So its working before application is being published. Once is published and installed doesn't work.

Any ideas why? Could anyone please help me with this problem?
Thank you in advance for your help.
AnswerRe: Backup/Restore - SQL Compact Edition Pin
Richard MacCutchan31-Oct-12 23:48
mveRichard MacCutchan31-Oct-12 23:48 
AnswerRe: Backup/Restore - SQL Compact Edition Pin
Simon_Whale1-Nov-12 0:47
Simon_Whale1-Nov-12 0:47 
GeneralRe: Backup/Restore - SQL Compact Edition Pin
saturnuk1-Nov-12 0:58
saturnuk1-Nov-12 0:58 
GeneralRe: Backup/Restore - SQL Compact Edition Pin
Eddy Vluggen1-Nov-12 1:55
professionalEddy Vluggen1-Nov-12 1:55 
GeneralRe: Backup/Restore - SQL Compact Edition Pin
GrooverFromHolland2-Nov-12 10:46
GrooverFromHolland2-Nov-12 10:46 
QuestionInfragistics Tree With Checkboxes Pin
Kevin Marois31-Oct-12 12:49
professionalKevin Marois31-Oct-12 12:49 
AnswerRe: Infragistics Tree With Checkboxes Pin
Pete O'Hanlon31-Oct-12 13:26
mvePete O'Hanlon31-Oct-12 13:26 
GeneralRe: Infragistics Tree With Checkboxes Pin
Kevin Marois31-Oct-12 13:28
professionalKevin Marois31-Oct-12 13:28 
AnswerRe: Infragistics Tree With Checkboxes Pin
Mycroft Holmes31-Oct-12 16:29
professionalMycroft Holmes31-Oct-12 16:29 
GeneralRe: Infragistics Tree With Checkboxes Pin
Kevin Marois31-Oct-12 18:41
professionalKevin Marois31-Oct-12 18:41 
Question921600 Pin
C-P-User-331-Oct-12 12:47
C-P-User-331-Oct-12 12:47 
AnswerRe: 921600 Pin
Pete O'Hanlon31-Oct-12 13:24
mvePete O'Hanlon31-Oct-12 13:24 
GeneralRe: 921600 Pin
C-P-User-31-Nov-12 7:00
C-P-User-31-Nov-12 7:00 
GeneralRe: 921600 Pin
C-P-User-31-Nov-12 7:08
C-P-User-31-Nov-12 7:08 
GeneralRe: 921600 Pin
Pete O'Hanlon1-Nov-12 7:32
mvePete O'Hanlon1-Nov-12 7:32 
GeneralRe: 921600 Pin
C-P-User-35-Nov-12 6:19
C-P-User-35-Nov-12 6:19 
GeneralRe: 921600 Pin
Pete O'Hanlon5-Nov-12 6:58
mvePete O'Hanlon5-Nov-12 6:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.