Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Can I create a Workspace without using IWorkspaceFactory.Create

I am trying to create a Workspace without specifying it's parent directory, is that possible ?

share|improve this question
add comment

2 Answers 2

Use a ScratchWorkspace. They are basically temporary local GeoDatabases that have full (single-user) GDB functionality. To create them, you don't need to specify anything. After you release the last reference, they get deleted.

share|improve this answer
1  
Thanks for the reply, but Scratch Workspaces were designed to be created and used within a single session. If an application is started again at a later time, there is no reliable method for retrieving data that was previously stored in a ScratchWorkspace. –  Seem Apr 2 '13 at 9:58
1  
I guess if you do want it to be permanent, where do you want it to live (since wanting them to be permanent means that you want to access it again)? One option is to get the current user directory stackoverflow.com/questions/1140383/… and then generate a unique file name stackoverflow.com/questions/1602578/… . Append those two things and pass them to the IWorkspaceFactory.Create and you will have a permanent unique workspace –  Ragi Yaser Burhum Apr 2 '13 at 17:56
add comment

I am not sure if it is possible not to use the .Create method, but i can giveyou an advice:

try to use the InMemoryWorkSpaceFactory:

/// <summary>
    /// Creates a workspace that resides in memory
    /// </summary>
    /// <returns>A feature workspace</returns>
    public static IFeatureWorkspace GetFeatureWorkspace()
    {
        InMemoryWorkspaceFactory workspaceFactory = new InMemoryWorkspaceFactoryClass();
        IWorkspaceName workspaceName = workspaceFactory.Create(string.Empty, "Workspace", null, 0);

        IName name = (IName)workspaceName;
        IWorkspace inmemWor = (IWorkspace)name.Open();

        return (IFeatureWorkspace)inmemWor;
    }

This kind of workspace does not require a path; but a withdraw is that has limited functionality in version 10 i.e: I was not able to update features created by a locator, in other hand in version 9.x it was possible.

share|improve this answer
    
Thanks a lot for you reply, as you can see InMemoryWorkSpaceFactory is used to create a temporary workspace that is stored in memory. So if I wanted to user the created Workspace again after releasing all of it's references, it will not be possible. –  Seem Apr 2 '13 at 10:01
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.