path

Modify path string to improve robustness

泄露秘密 提交于 2019-12-17 17:07:11
问题 I have a a string for a path for a file my program reads data from. I want to improve the robustness and I recall seeing someone do .\blabla\blalbla\ but I'm finding it a bit hard to find a topic that explains how this work so I can implement it into my program. My path (I'm aware that the naming isn't correct but it'd interfere with my property if I named it with a capital P) private const string path = @"C:\Users\zain\Desktop\program_storage\AccountDatabase.txt"; I'd like it to be something

Expand tilde to home directory

為{幸葍}努か 提交于 2019-12-17 16:43:14
问题 I have a program that accepts a destination folder where files will be created. My program should be able to handle absolute paths as well as relative paths. My problem is that I don't know how to expand ~ to the home directory. My function to expand the destination looks like this. If the path given is absolute it does nothing otherwise it joins the relative path with the current working directory. import "path" import "os" // var destination *String is the user input func expandPath() { if

Use wildcard with os.path.isfile()

ぃ、小莉子 提交于 2019-12-17 16:34:08
问题 I'd like to check if there are any .rar files in a directory. it doesn’t need to be recursive. Using wildcard with os.path.isfile() was my best guess, but it doesn't work. What can I do then? Thanks. 回答1: glob is what you need. >>> import glob >>> glob.glob('*.rar') # all rar files within the directory, in this case the current working one os.path.isfile() returns True if a path is an existing regular file. So that is used for checking whether a file already exists and doesn't support

How to Clip a Star in android ? But the appearance of the star is clear

╄→гoц情女王★ 提交于 2019-12-17 16:33:16
问题 First to see the below images. package com.syncfusion.rating; import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.Path; import android.graphics.Region; import android.view.View; /** * Created by chozarajan.pandiyarajan on 10/9/2015. */ public class SfRatingItem extends View { private int fillColor,minDim,topXPoint,topYPoint; private double bigHypot,bigA,bigB,littleHypot,littleA,littleB,value;

How to remove bad path characters in Python?

前提是你 提交于 2019-12-17 16:27:18
问题 What is the most cross platform way of removing bad path characters (e.g. "\" or ":" on Windows) in Python? Solution Because there seems to be no ideal solution I decided to be relatively restrictive and did use the following code: def remove(value, deletechars): for c in deletechars: value = value.replace(c,'') return value; print remove(filename, '\/:*?"<>|') 回答1: Unfortunately, the set of acceptable characters varies by OS and by filesystem. Windows: Use almost any character in the current

Loading a file relative to the executing jar file

元气小坏坏 提交于 2019-12-17 16:07:51
问题 The question says it all. The specialty in my case is that the current working directory is not the location of the jar file but c:\Windows\system32 (My jar file is started by windows using the right-click-menu, i want to pass a folder's path as a parameter to the jar). Now I want to load a configuration file called config.xml that is in the same folder as the jar. The purpose of the file is, of course, to provide settings for the jar. It is important for me that the xml file is outside of

What's the relative order with which Windows search for executable files in PATH?

心不动则不痛 提交于 2019-12-17 15:53:40
问题 If I have a.com, a.cmd, a.bat, and a.exe files %PATH%, which one would Windows pick if I invoke just the command "a"? Is this officially spec-ed somewhere by M$? I just wanted to wrap my gvim.exe executable with -n, but my gvim.bat doesn't appear to get run neither from the command line, nor from the Run dialog. 回答1: See the command search sequence on Microsoft Technet The PATH and PATHEXT environmental variables each provide an element of the search sequence: PATH is the ordered list of

How can I determine if a given drive letter is a local, mapped, or USB drive?

我是研究僧i 提交于 2019-12-17 15:39:03
问题 Given the letter of a drive, how can I determine what type of drive it is? For example, whether E:\ is a USB drive, a network drive or a local hard drive. 回答1: Have a look at DriveInfo's DriveType property. System.IO.DriveInfo[] drives = System.IO.DriveInfo.GetDrives(); foreach (var drive in drives) { string driveName = drive.Name; // C:\, E:\, etc:\ System.IO.DriveType driveType = drive.DriveType; switch (driveType) { case System.IO.DriveType.CDRom: break; case System.IO.DriveType.Fixed: //

Remove unwanted path name from %path% variable via batch

落爺英雄遲暮 提交于 2019-12-17 15:36:22
问题 Scope: Windows XP or newer Tools: Batch script I need to be able to remove an unneeded path name from the system %PATH% variable. I know how to add a new path name to the system %PATH% variable, using a tool such as SETX.EXE, which also makes it immediately available within the existing CMD environment. It's probably a matter of using FIND and/or a FOR loop of some kind, but I'm not quite sure how to accomplish this. Here's a sample path statement... %PATH% = C:\;C:\Program Files\Common Files

System versus user PATH environmental variable…winmerge works only if I add the path to the user PATH

谁都会走 提交于 2019-12-17 15:24:47
问题 If I add C:\Program Files (x86)\WinMerge to the User PATH variable(by right click on computer -> advanced system settings -> environmental variables), once I open a new cmd shell WinmergeU.exe is not recognized. If I add that path to the System PATH variable, WinmergeU.exe is correctly recognized instead. I though there was no difference between User and System, beside the fact that if I set it on System all the users will see it, while the User PATH is local. Am I doing something wrong? EDIT