© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
9 replies
HyperSilver69

❔ Referring to a file in C#

Hello, I have a file (.shader) in my Solution directory, however I'm trying to refer to it in code, I have tried
        void Start()
        {
            fileEntries = Directory.GetFiles(@"D:\BorderLandsMod");
            foreach (String file in fileEntries)
            {
                if (file == "LoveShader.shader")
                {
                    Shader shader = file;
                }
                else
                {
                    return;
                }
            }
        void Start()
        {
            fileEntries = Directory.GetFiles(@"D:\BorderLandsMod");
            foreach (String file in fileEntries)
            {
                if (file == "LoveShader.shader")
                {
                    Shader shader = file;
                }
                else
                {
                    return;
                }
            }

However, that returns
Cannot implicitly convert from type 'string' to 'unityEngine.Shader
Cannot implicitly convert from type 'string' to 'unityEngine.Shader
. Any help would be relaly appreciated!
image.png
image.png
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ Read a .pdb file in C#
C#CC# / help
3y ago
❔ How to run a c# file
C#CC# / help
3y ago
✅ keyauth to c# file
C#CC# / help
2y ago
Reading in a File C# 2D arrays
C#CC# / help
2y ago