当前位置: 首页>>代码示例>>C#>>正文


C# IOConnectionInfo.IsLocalFile方法代码示例

本文整理汇总了C#中IOConnectionInfo.IsLocalFile方法的典型用法代码示例。如果您正苦于以下问题:C# IOConnectionInfo.IsLocalFile方法的具体用法?C# IOConnectionInfo.IsLocalFile怎么用?C# IOConnectionInfo.IsLocalFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IOConnectionInfo的用法示例。


在下文中一共展示了IOConnectionInfo.IsLocalFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Initialize

		private void Initialize(IOConnectionInfo iocBaseFile, bool bTransacted)
		{
			if(iocBaseFile == null) throw new ArgumentNullException("iocBaseFile");

			m_bTransacted = bTransacted;
			m_iocBase = iocBaseFile.CloneDeep();

			string strPath = m_iocBase.Path;

			if(m_iocBase.IsLocalFile())
			{
				try
				{
					if(File.Exists(strPath))
					{
						// Symbolic links are realized via reparse points;
						// https://msdn.microsoft.com/en-us/library/windows/desktop/aa365503.aspx
						// https://msdn.microsoft.com/en-us/library/windows/desktop/aa365680.aspx
						// https://msdn.microsoft.com/en-us/library/windows/desktop/aa365006.aspx
						// Performing a file transaction on a symbolic link
						// would delete/replace the symbolic link instead of
						// writing to its target
						FileAttributes fa = File.GetAttributes(strPath);
						if((long)(fa & FileAttributes.ReparsePoint) != 0)
							m_bTransacted = false;
					}
				}
				catch(Exception) { Debug.Assert(false); }
			}

#if !KeePassUAP
			// Prevent transactions for FTP URLs under .NET 4.0 in order to
			// avoid/workaround .NET bug 621450:
			// https://connect.microsoft.com/VisualStudio/feedback/details/621450/problem-renaming-file-on-ftp-server-using-ftpwebrequest-in-net-framework-4-0-vs2010-only
			if(strPath.StartsWith("ftp:", StrUtil.CaseIgnoreCmp) &&
				(Environment.Version.Major >= 4) && !NativeLib.IsUnix())
				m_bTransacted = false;
#endif

			foreach(KeyValuePair<string, bool> kvp in g_dEnabled)
			{
				if(strPath.StartsWith(kvp.Key, StrUtil.CaseIgnoreCmp))
				{
					m_bTransacted = kvp.Value;
					break;
				}
			}

			if(m_bTransacted)
			{
				m_iocTemp = m_iocBase.CloneDeep();
				m_iocTemp.Path += StrTempSuffix;
			}
			else m_iocTemp = m_iocBase;
		}
开发者ID:joshuadugie,项目名称:KeePass-2.x,代码行数:55,代码来源:FileTransactionEx.cs

示例2: CheckForFileChangeFast

 public bool CheckForFileChangeFast(IOConnectionInfo ioc, string previousFileVersion)
 {
     if (!ioc.IsLocalFile())
         return false;
     if (previousFileVersion == null)
         return false;
     DateTime previousDate;
     if (!DateTime.TryParse(previousFileVersion, CultureInfo.InvariantCulture, DateTimeStyles.None, out previousDate))
         return false;
     DateTime currentModificationDate = File.GetLastWriteTimeUtc(ioc.Path);
     TimeSpan diff = currentModificationDate - previousDate;
     return diff > TimeSpan.FromSeconds(1);
     //don't use > operator because milliseconds are truncated
     //return File.GetLastWriteTimeUtc(ioc.Path) - previousDate >= TimeSpan.FromSeconds(1);
 }
开发者ID:pythe,项目名称:wristpass,代码行数:15,代码来源:BuiltInFileStorage.cs

示例3: OpenWrite

        public static Stream OpenWrite(IOConnectionInfo ioc)
        {
            if(ioc.IsLocalFile()) return OpenWriteLocal(ioc);

            return CreateWebClient(ioc).OpenWrite(new Uri(ioc.Path));
        }
开发者ID:jonbws,项目名称:strengthreport,代码行数:6,代码来源:IOConnection.cs

示例4: Launch

        public static void Launch(Activity act, IOConnectionInfo ioc, AppTask appTask)
        {
            if (ioc.IsLocalFile())
            {
                Launch(act, ioc.Path, appTask);
                return;
            }

            Intent i = new Intent(act, typeof(PasswordActivity));

            PutIoConnectionToIntent(ioc, i);
            i.SetFlags(ActivityFlags.ForwardResult);

            appTask.ToIntent(i);

            act.StartActivity(i);
        }
开发者ID:pythe,项目名称:wristpass,代码行数:17,代码来源:PasswordActivity.cs

示例5: GetKeyAssocID

        private static string GetKeyAssocID(IOConnectionInfo iocDb)
        {
            if(iocDb == null) throw new ArgumentNullException("iocDb");

            string strDb = iocDb.Path;
            if((strDb.Length > 0) && iocDb.IsLocalFile() &&
                !UrlUtil.IsAbsolutePath(strDb))
                strDb = UrlUtil.MakeAbsolutePath(WinUtil.GetExecutable(), strDb);

            return strDb;
        }
开发者ID:saadware,项目名称:kpn,代码行数:11,代码来源:AceDefaults.cs

示例6: CompleteConnectionInfo

		internal static IOConnectionInfo CompleteConnectionInfo(IOConnectionInfo ioc,
			bool bSave, bool bCanRememberCred, bool bTestConnection, bool bForceShow)
		{
			if(ioc == null) { Debug.Assert(false); return null; }
			if(!bForceShow && ((ioc.CredSaveMode == IOCredSaveMode.SaveCred) ||
				ioc.IsLocalFile() || ioc.IsComplete))
				return ioc.CloneDeep();

			IOConnectionForm dlg = new IOConnectionForm();
			dlg.InitEx(bSave, ioc.CloneDeep(), bCanRememberCred, bTestConnection);
			if(UIUtil.ShowDialogNotValue(dlg, DialogResult.OK)) return null;

			IOConnectionInfo iocResult = dlg.IOConnectionInfo;
			UIUtil.DestroyForm(dlg);
			return iocResult;
		}
开发者ID:riking,项目名称:go-keepass2,代码行数:16,代码来源:MainForm_Functions.cs

示例7: OpenWrite

        public static Stream OpenWrite(IOConnectionInfo ioc)
        {
            if(ioc == null) { Debug.Assert(false); return null; }

            RaiseIOAccessPreEvent(ioc, IOAccessType.Write);

            if(ioc.IsLocalFile()) return OpenWriteLocal(ioc);

            Uri uri = new Uri(ioc.Path);
            Stream s;

            // Mono does not set HttpWebRequest.Method to POST for writes,
            // so one needs to set the method to PUT explicitly
            if(NativeLib.IsUnix() && (uri.Scheme.Equals(Uri.UriSchemeHttp,
                StrUtil.CaseIgnoreCmp) || uri.Scheme.Equals(Uri.UriSchemeHttps,
                StrUtil.CaseIgnoreCmp)))
                s = CreateWebClient(ioc).OpenWrite(uri, WebRequestMethods.Http.Put);
            else s = CreateWebClient(ioc).OpenWrite(uri);

            return IocStream.WrapIfRequired(s);
        }
开发者ID:haro-freezd,项目名称:KeePass,代码行数:21,代码来源:IOConnection.cs

示例8: FileExists

        public static bool FileExists(IOConnectionInfo ioc, bool bThrowErrors)
        {
            if(ioc == null) { Debug.Assert(false); return false; }

            RaiseIOAccessPreEvent(ioc, IOAccessType.Exists);

            if(ioc.IsLocalFile()) return File.Exists(ioc.Path);

            #if (!KeePassLibSD && !KeePassRT)
            if(ioc.Path.StartsWith("ftp://", StrUtil.CaseIgnoreCmp))
            {
                bool b = SendCommand(ioc, WebRequestMethods.Ftp.GetDateTimestamp);
                if(!b && bThrowErrors) throw new InvalidOperationException();
                return b;
            }
            #endif

            try
            {
                Stream s = OpenRead(ioc);
                if(s == null) throw new FileNotFoundException();

                try { s.ReadByte(); }
                catch(Exception) { }

                // We didn't download the file completely; close may throw
                // an exception -- that's okay
                try { s.Close(); }
                catch(Exception) { }
            }
            catch(Exception)
            {
                if(bThrowErrors) throw;
                return false;
            }

            return true;
        }
开发者ID:haro-freezd,项目名称:KeePass,代码行数:38,代码来源:IOConnection.cs

示例9: OpenRead

        public static Stream OpenRead(IOConnectionInfo ioc)
        {
            RaiseIOAccessPreEvent(ioc, IOAccessType.Read);

            if(StrUtil.IsDataUri(ioc.Path))
            {
                byte[] pbData = StrUtil.DataUriToData(ioc.Path);
                if(pbData != null) return new MemoryStream(pbData, false);
            }

            if(ioc.IsLocalFile()) return OpenReadLocal(ioc);

            return IocStream.WrapIfRequired(CreateWebClient(ioc).OpenRead(
                new Uri(ioc.Path)));
        }
开发者ID:haro-freezd,项目名称:KeePass,代码行数:15,代码来源:IOConnection.cs

示例10: OpenWrite

		public static Stream OpenWrite(IOConnectionInfo ioc)
		{
			if(ioc == null) { Debug.Assert(false); return null; }

			if(ioc.IsLocalFile()) return OpenWriteLocal(ioc);

			return CreateWebClient(ioc).OpenWrite(new Uri(ioc.Path));
		}
开发者ID:ComradeP,项目名称:KeePass-2.x,代码行数:8,代码来源:IOConnection.cs

示例11: SetKeySource

        public void SetKeySource(IOConnectionInfo ioDatabase, string strKeySource,
            bool bIsKeyFile)
        {
            if(ioDatabase == null) throw new ArgumentNullException("ioDatabase");

            string strDb = ioDatabase.Path;
            if((strDb.Length > 0) && ioDatabase.IsLocalFile() &&
                !UrlUtil.IsAbsolutePath(strDb))
                strDb = UrlUtil.MakeAbsolutePath(WinUtil.GetExecutable(), strDb);

            string strKey = strKeySource;
            if(bIsKeyFile && !string.IsNullOrEmpty(strKey))
            {
                if(StrUtil.IsDataUri(strKey))
                    strKey = null; // Don't remember data URIs
                else if(!UrlUtil.IsAbsolutePath(strKey))
                    strKey = UrlUtil.MakeAbsolutePath(WinUtil.GetExecutable(), strKey);
            }

            if(!m_bRememberKeySources) strKey = null;

            foreach(AceKeyAssoc kfp in m_vKeySources)
            {
                if(strDb.Equals(kfp.DatabasePath, StrUtil.CaseIgnoreCmp))
                {
                    if(string.IsNullOrEmpty(strKey)) m_vKeySources.Remove(kfp);
                    else
                    {
                        kfp.KeyFilePath = (bIsKeyFile ? strKey : string.Empty);
                        kfp.KeyProvider = (bIsKeyFile ? string.Empty : strKey);
                    }
                    return;
                }
            }

            if(string.IsNullOrEmpty(strKey)) return;

            AceKeyAssoc kfpNew = new AceKeyAssoc();
            kfpNew.DatabasePath = strDb;
            if(bIsKeyFile) kfpNew.KeyFilePath = strKey;
            else kfpNew.KeyProvider = strKey;
            m_vKeySources.Add(kfpNew);
        }
开发者ID:amiryal,项目名称:keepass2,代码行数:43,代码来源:AceDefaults.cs

示例12: GetKeySource

        public string GetKeySource(IOConnectionInfo ioDatabase, bool bGetKeyFile)
        {
            if(ioDatabase == null) throw new ArgumentNullException("ioDatabase");

            string strDb = ioDatabase.Path;
            if((strDb.Length > 0) && ioDatabase.IsLocalFile() &&
                !UrlUtil.IsAbsolutePath(strDb))
                strDb = UrlUtil.MakeAbsolutePath(WinUtil.GetExecutable(), strDb);

            foreach(AceKeyAssoc kfp in m_vKeySources)
            {
                if(strDb.Equals(kfp.DatabasePath, StrUtil.CaseIgnoreCmp))
                    return (bGetKeyFile ? kfp.KeyFilePath : kfp.KeyProvider);
            }

            return null;
        }
开发者ID:amiryal,项目名称:keepass2,代码行数:17,代码来源:AceDefaults.cs

示例13: RequiresCredentials

 public bool RequiresCredentials(IOConnectionInfo ioc)
 {
     return (!ioc.IsLocalFile()) && (ioc.CredSaveMode != IOCredSaveMode.SaveCred);
 }
开发者ID:pythe,项目名称:wristpass,代码行数:4,代码来源:BuiltInFileStorage.cs

示例14: IsReadOnly

        public bool IsReadOnly(IOConnectionInfo ioc)
        {
            if (ioc.IsLocalFile())
            {
                if (IsLocalFileFlaggedReadOnly(ioc))
                    return true;
                if (IsReadOnlyBecauseKitkatRestrictions(ioc))
                    return true;

                return false;
            }
            //for remote files assume they can be written: (think positive! :-) )
            return false;
        }
开发者ID:pythe,项目名称:wristpass,代码行数:14,代码来源:BuiltInFileStorage.cs

示例15: GetCurrentFileVersionFast

 public string GetCurrentFileVersionFast(IOConnectionInfo ioc)
 {
     if (ioc.IsLocalFile())
     {
         return File.GetLastWriteTimeUtc(ioc.Path).ToString(CultureInfo.InvariantCulture);
     }
     else
     {
         return DateTime.MinValue.ToString(CultureInfo.InvariantCulture);
     }
 }
开发者ID:pythe,项目名称:wristpass,代码行数:11,代码来源:BuiltInFileStorage.cs


注:本文中的IOConnectionInfo.IsLocalFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。