//Done on background thread
 private static void UploadFile(string path)
 {
     Byte[] contents;
     try
     {
         contents = File.ReadAllBytes(path);
     }
     catch (Exception ex)
     {
         Debug.Print("Failed to read file contents.  "+ ex.Message);
         return;
     }
     var db = new FishTaggingDataContext();
     var file = new RawDataFile
     {
         FileName = Path.GetFileName(path),
         FolderName = Path.GetDirectoryName(path),
         Contents = contents
     };
     db.RawDataFiles.InsertOnSubmit(file);
     try
     {
         db.SubmitChanges();
     }
     catch (Exception ex)
     {
         Debug.Print("Failed to submit file.  " + ex.Message);
     }
 }
Example #2
0
        //Done on background thread
        static private void UploadFile(string path)
        {
            Byte[] contents;
            try
            {
                contents = File.ReadAllBytes(path);
            }
            catch (Exception ex)
            {
                Debug.Print("Failed to read file contents.  " + ex.Message);
                return;
            }
            var db   = new FishTaggingDataContext();
            var file = new RawDataFile
            {
                FileName   = Path.GetFileName(path),
                FolderName = Path.GetDirectoryName(path),
                Contents   = contents
            };

            db.RawDataFiles.InsertOnSubmit(file);
            try
            {
                db.SubmitChanges();
            }
            catch (Exception ex)
            {
                Debug.Print("Failed to submit file.  " + ex.Message);
            }
        }