private static IStream CreateStreamOnFile()

in AppInstallerFileBuilder/AppInstallerFileBuilderLib/IO/StreamUtils.cs [219:272]


        private static IStream CreateStreamOnFile(
            string fileName,
            STGM mode,
            uint attributes,
            bool create,
            object cloudStreamHandler)
        {
            if (fileName == null)
            {
                throw new ArgumentNullException("fileName");
            }

            try
            {
                if (IsValidCloudStreamUri(fileName) && cloudStreamHandler != null)
                {
                    Type cloudStreamHandlerType = cloudStreamHandler.GetType();
                    MethodInfo getStreamMethod = cloudStreamHandlerType.GetMethod("GetStream");

                    // MethodInfo equal operator is not defined on TestNet, so we cast to object to do null check
                    if ((object)getStreamMethod == null)
                    {
                        throw new MissingMethodException("The GetStream method cannot be found.");
                    }

                    object[] args = new object[] { fileName, (UInt32)mode, null };
                    getStreamMethod.Invoke(cloudStreamHandler, args);
                    if (args[2] != null)
                    {
                        return (IStream)args[2];
                    }
                    else
                    {
                        throw new FileNotFoundException("Failed to create cloud stream on input address.", fileName);
                    }
                }
                else
                {
                    return SHCreateStreamOnFileEx(fileName, mode, attributes, create, null);
                }
            }
            catch (FileNotFoundException e)
            {
                // Ensure that the exception has a file name attached.
                if (string.IsNullOrEmpty(e.FileName))
                {
                    throw new FileNotFoundException(e.Message, fileName, e.InnerException);
                }
                else
                {
                    throw e;
                }
            }
        }