Error 0x80044a08: ‘invalid character in file name’

If you try to upload a file to a note in your crm system, you have to make sure that the property filename of the annotation only contains the filename. If it contains for example the drive letters you will receive the error 0x80044a08.

The easiest way to ensure that the filename contains only the file name is to use Path.GetFileName( … );

See the ‘corrected’ sdk example below

// Open a file and read the contents into a byte array.
FileStream stream = File.OpenRead("some-path-pointing-to-a-file-in-here");
byte[] byteData = new byte[stream.Length];
stream.Read(byteData, 0, byteData.Length);
// Encode the data using base64.
string encodedData = System.Convert.ToBase64String(byteData);
// Now update the note.
annotation updateNote = new annotation();
updateNote.annotationid = new Key();
updateNote.annotationid.Value = createdNoteId;
updateNote.documentbody = encodedData;
updateNote.filename = Path.GetFileName("some-path-pointing-to-a-file-in-here");
updateNote.mimetype = @"application\ms-word";

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.