Community
Vault Customization
Share your knowledge, ask questions, and explore popular Vault API, Data Standard, and VBA topics related to programming, creating add-ins, or working with the Vault API.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

File ID is Invalid

2 REPLIES 2
Reply
Message 1 of 3
amitnkukanur
655 Views, 2 Replies

File ID is Invalid

Hello,

 

I am doing a Vault Customization using C# as development language in Visual Studio 2010.

 

Refer the below code

 

using (FileStream stream = newFileStream(filePath, FileMode.Open, FileAccess.Read))

{

ByteArray fileData = newByteArray();

fileData.Bytes = newbyte[stream.Length];

stream.Read(fileData.Bytes, 0, fileData.Bytes.Length);

serviceManager.DocumentService.AddFile(folderId, Path.GetFileName(filePath), "Test", System.IO.File.GetLastWriteTime(filePath), null, null, FileClassification.DesignVisualization, false, fileData);

}

 

Using this above code which is present in SDK i am inserting files to Vault.

 

Again for some operation if i want to do certain operation on this file using its file id i get error as

 

1013 GetFileFailed Cannot get file (file id is invalid).

 

When i have inserted this file using this above mentioned method i get the error

 

Autodesk.Connectivity.WebServices.File test = mgr.DocumentService.GetFileById(fle.Id);

 

Here fle.ID is the ID of that inserted file which i get using iteration.

 

Please help.

 

Cheers,

Amit

 

Senior Software Engineer
2 REPLIES 2
Message 2 of 3
smithmat
in reply to: amitnkukanur

  • What version of Vault.  
  • Can you provide a small but complete code example that demonstrates the problem?
Message 3 of 3
amitnkukanur
in reply to: smithmat

Hi,

 

I am using Vault 2013 Professional.

 

Here i an adding a new DWF file using the above mentioned code.

 

Then i attach the dwf file to DWG/IDW.

 

            long AttachmentFileID = 0;
            foreach (Autodesk.Connectivity.WebServices.File fle in Files)
            {
                //if(fle.Name.Equals(kCheckOutPath.Replace(".idw",".dwf")))
                if (fle.Name.Equals(System.IO.Path.GetFileName(kCheckOutPath.Replace(".idw", ".dwf"))))
                {
                     AttachmentFileID = fle.Id;
                    Autodesk.Connectivity.WebServices.File pFile = mgr.DocumentService.GetLatestFileByMasterId(Main_File_Master_ID);

                    //Autodesk.Connectivity.WebServices.File pFile = mgr.DocumentService.GetLatestFileByMasterId(file.MasterId);
                    FileAssocParam fileParam1 = new FileAssocParam();
                    fileParam1.CldFileId = fle.MasterId; ;
                    fileParam1.ExpectedVaultPath = folders[0].FullName + "/" + System.IO.Path.GetFileName(kCheckOutPath.Replace(".idw", ".dwf"));
                    fileParam1.Source = "";
                    fileParam1.RefId = "";
                    fileParam1.Typ = AssociationType.Attachment;
                    mgr.DocumentService.AddDesignVisualizationFileAttachment(pFile.Id, fileParam1);
                    //mgr.DocumentService.AddDesignVisualizationFileAttachment(file.Id, fileParam1);

                    System.IO.File.Delete(kCheckOutPath.Replace(".idw", ".dwf"));
                }
            }

 

Here i am attaching the dwf to available IDW/DWG.

 

But i am getting problem on AddDesignVisualizationFileAttachment line.

 

 

Then i checked this below line

 

Autodesk.Connectivity.WebServices.File test = mgr.DocumentService.GetFileById(fle.Id);

 

I found out that the added file id is improper.

 

This is where problem lies, i am trying to attach a dwf file to existing idw/dwg but its not allowing me to attach. Before attaching i will remove the previous attachment present if any and attach new one.

 

Can you suggest me where am i going wrong.

 

rgds

Amit

 

Senior Software Engineer

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report