System.IO.IsolatedStorage.IsolatedStorageFile.GetFullPath C# (CSharp) Method

GetFullPath() private method

private GetFullPath ( string partialPath ) : string
partialPath string
return string
        internal string GetFullPath(string partialPath)
        {
            Debug.Assert(partialPath != null, "partialPath should be non null");

            int i;

            // Chop off directory separator characters at the start of the string because they counfuse Path.Combine.
            for (i = 0; i < partialPath.Length; i++)
            {
                if (partialPath[i] != Path.DirectorySeparatorChar && partialPath[i] != Path.AltDirectorySeparatorChar)
                {
                    break;
                }
            }

            partialPath = partialPath.Substring(i);

            return Path.Combine(RootDirectory, partialPath);
        }

Usage Example

        // If the isolated storage file is null, then we default to using a file
        // that is scoped by user, appdomain, and assembly.
        public IsolatedStorageFileStream(String path, FileMode mode,
                                         FileAccess access, FileShare share, int bufferSize,
                                         IsolatedStorageFile isf)
        {
            if (path == null)
            {
                throw new ArgumentNullException(nameof(path));
            }
            Contract.EndContractBlock();

            if ((path.Length == 0) || path.Equals(s_BackSlash))
            {
                throw new ArgumentException(
                          SR.IsolatedStorage_Path);
            }

            if (isf == null)
            {
                throw new ArgumentNullException(nameof(isf));
            }

            if (isf.Disposed)
            {
                throw new ObjectDisposedException(null, SR.IsolatedStorage_StoreNotOpen);
            }

            switch (mode)
            {
            case FileMode.CreateNew:            // Assume new file
            case FileMode.Create:               // Check for New file & Unreserve
            case FileMode.OpenOrCreate:         // Check for new file
            case FileMode.Truncate:             // Unreserve old file size
            case FileMode.Append:               // Check for new file
            case FileMode.Open:                 // Open existing, else exception
                break;

            default:
                throw new ArgumentException(SR.IsolatedStorage_FileOpenMode);
            }

            _isf       = isf;
            _givenPath = path;
            _fullPath  = _isf.GetFullPath(_givenPath);

            try
            {
                _fs = new
                      FileStream(_fullPath, mode, access, share, bufferSize,
                                 FileOptions.None);
            }
            catch (Exception e)
            {
                // Exception message might leak the IsolatedStorage path. The desktop prevented this by calling an
                // internal API which made sure that the exception message was scrubbed. However since the innerException
                // is never returned to the user(GetIsolatedStorageException() does not populate the innerexception
                // in retail bits we leak the path only under the debugger via IsolatedStorageException._underlyingException which
                // they can any way look at via IsolatedStorageFile instance as well.
                throw IsolatedStorageFile.GetIsolatedStorageException("IsolatedStorage_Operation_ISFS", e);
            }
        }
All Usage Examples Of System.IO.IsolatedStorage.IsolatedStorageFile::GetFullPath