#unity/日常积累 通过SubString()就可以获取到物体所在文件夹了 ![[Pasted image 20230224120953.png]] 如果文件夹不存在,就创建: ``` cs public void AddResource() { currentLobbyCameraAnimationPath = $"Assets/BundleResources/CommonRegion/OutsideGame/Skins/Characters/{RoleIndex}/SkinParts/{NumberIndex}/RelatedResources/ani&{NumberIndex}_LobbyCameraAnimation_Height.anim"; string path = currentLobbyCameraAnimationPath.Substring(0, currentLobbyCameraAnimationPath.LastIndexOf(@"/")); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } } ```