コード例 #1
0
        /// <summary>
        /// Guesses the name of the local file.
        /// </summary>
        private void GuessLocalFileName()
        {
            try
            {
                int index = sourceLocation.LastIndexOf("/");

                if ((index != -1) && (index + 1 < sourceLocation.Length))
                {
                    LocalName = sourceLocation.Substring(index + 1);
                }
                else
                {
                    LocalName = sourceLocation;
                }

                if (LocalName.IndexOf(".") == -1)
                {
                    LocalName = LocalName + "." + suggestedMimeType.GetFileExtension();
                }
            }
            catch (Exception)
            {
                if (LocalName == null)
                {
                    LocalName = Guid.NewGuid() + "." + suggestedMimeType.GetFileExtension();
                }
            }
        }