Click here to Skip to main content
15,941,755 members
Home / Discussions / C#
   

C#

 
GeneralRe: Error: "Could not use"file name"; file already in use." Pin
Marat Beiner5-Feb-11 23:18
Marat Beiner5-Feb-11 23:18 
GeneralRe: Error: "Could not use"file name"; file already in use." Pin
OriginalGriff5-Feb-11 23:24
mveOriginalGriff5-Feb-11 23:24 
GeneralRe: Error: "Could not use"file name"; file already in use." Pin
Marat Beiner5-Feb-11 23:30
Marat Beiner5-Feb-11 23:30 
GeneralRe: Error: "Could not use"file name"; file already in use." Pin
OriginalGriff5-Feb-11 23:32
mveOriginalGriff5-Feb-11 23:32 
GeneralRe: Error: "Could not use"file name"; file already in use." Pin
Marat Beiner5-Feb-11 23:37
Marat Beiner5-Feb-11 23:37 
GeneralRe: Error: "Could not use"file name"; file already in use." Pin
OriginalGriff5-Feb-11 23:42
mveOriginalGriff5-Feb-11 23:42 
GeneralRe: Error: "Could not use"file name"; file already in use." Pin
Marat Beiner5-Feb-11 23:57
Marat Beiner5-Feb-11 23:57 
GeneralRe: Error: "Could not use"file name"; file already in use." Pin
OriginalGriff6-Feb-11 0:24
mveOriginalGriff6-Feb-11 0:24 
That's a good start! The problem now, is probably that the file is empty. So when Access tries to use it, it expects it to be a valid (if blank) Access DB.

Probably the easiest way is to:
1) Manually prepare a blank database (set up your tables and so forth, but do not add any data: call it "MyBlankDB.accdb") and add it to your project.
2) Set it's properties to "embedded resource"
3) Use this to create your file:
System.Reflection.Assembly objAssembly = System.Reflection.Assembly.GetExecutingAssembly();
using (Stream blankDBData = objAssembly.GetManifestResourceStream("MyBlankDB.accdb"))
    {
    byte[] data = new Byte[blankDBData.Length];
    blankDBData.Read(data, 0, (int) blankDBData.Length);
    blankDBData.Close();
    using (FileStream newDBFile = new FileStream(pathToWhereIWantToPutTheDatabase, FileMode.Create))
        {
        newDBFile.Write(data, 0, (int) blankDBData.Length);
        newDBFile.Close();
        }
    }

Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.

Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."

AnswerRe: Error: "Could not use"file name"; file already in use." Pin
Eddy Vluggen6-Feb-11 1:09
professionalEddy Vluggen6-Feb-11 1:09 
AnswerRe: Error: "Could not use"file name"; file already in use." Pin
Henry Minute6-Feb-11 7:09
Henry Minute6-Feb-11 7:09 
AnswerRe: Error: "Could not use"file name"; file already in use." Pin
Marat Beiner6-Feb-11 7:22
Marat Beiner6-Feb-11 7:22 
GeneralRe: Error: "Could not use"file name"; file already in use." Pin
Henry Minute6-Feb-11 9:39
Henry Minute6-Feb-11 9:39 
QuestionUnity DI config implementation question Pin
Member 39190495-Feb-11 18:40
Member 39190495-Feb-11 18:40 
AnswerRe: Unity DI config implementation question Pin
Ravi Sant6-Feb-11 23:41
Ravi Sant6-Feb-11 23:41 
GeneralRe: Unity DI config implementation question Pin
Member 391904927-Feb-11 8:02
Member 391904927-Feb-11 8:02 
Questionquestion about delegates c# Pin
Gilbertu5-Feb-11 9:11
Gilbertu5-Feb-11 9:11 
AnswerRe: question about delegates c# PinPopular
OriginalGriff5-Feb-11 9:30
mveOriginalGriff5-Feb-11 9:30 
GeneralRe: question about delegates c# Pin
Gilbertu5-Feb-11 9:59
Gilbertu5-Feb-11 9:59 
GeneralRe: question about delegates c# Pin
OriginalGriff5-Feb-11 20:13
mveOriginalGriff5-Feb-11 20:13 
GeneralRe: question about delegates c# Pin
Richard MacCutchan5-Feb-11 21:26
mveRichard MacCutchan5-Feb-11 21:26 
GeneralRe: question about delegates c# Pin
OriginalGriff5-Feb-11 21:29
mveOriginalGriff5-Feb-11 21:29 
GeneralRe: question about delegates c# Pin
Gilbertu6-Feb-11 4:01
Gilbertu6-Feb-11 4:01 
GeneralRe: question about delegates c# Pin
OriginalGriff6-Feb-11 4:36
mveOriginalGriff6-Feb-11 4:36 
QuestionExtracting table from pdf in C# Pin
puneeth894-Feb-11 22:23
puneeth894-Feb-11 22:23 
AnswerRe: Extracting table from pdf in C# Pin
Henry Minute5-Feb-11 4:31
Henry Minute5-Feb-11 4:31 

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.